Hello, vbforums. This is my first post :P
Anyway, what I am wanting to do is add colors to certain words in a RichTextBox. I am reading .txt files into a RichTextBox, and I also want the user to have the option to color words as they like. It's easily done with - RichTextBox1.SelectionColor = Color.Red - but since the colors do not save to the .txt file, I am wanting to make "tags" in the .txt, such as - "[cr]"+"[/cr]" (which will stand for "colorred", and it should change the color of the text inside of these tags and hide the tags, but I just want to get the tags to work first). I'm not sure if "[cr]" + "[/cr]" is how it would be done, though. I was trying to keep the code simple, however, it's proving to be quite a pain. This is what I have, but it doesn't work:
(This is on Form1_Load)
I first did this, just to see if Find was doing anything, and it does:
Any help would be appreciated :)
I'm using VS 2012
Anyway, what I am wanting to do is add colors to certain words in a RichTextBox. I am reading .txt files into a RichTextBox, and I also want the user to have the option to color words as they like. It's easily done with - RichTextBox1.SelectionColor = Color.Red - but since the colors do not save to the .txt file, I am wanting to make "tags" in the .txt, such as - "[cr]"+"[/cr]" (which will stand for "colorred", and it should change the color of the text inside of these tags and hide the tags, but I just want to get the tags to work first). I'm not sure if "[cr]" + "[/cr]" is how it would be done, though. I was trying to keep the code simple, however, it's proving to be quite a pain. This is what I have, but it doesn't work:
(This is on Form1_Load)
Code:
If RichTextBox3.Find("[cr]" + "[/cr]") Then
RichTextBox3.SelectedText = "[cr]" + "[/cr]"
RichTextBox3.SelectionColor = Color.Red
RichTextBox3.Refresh()
Else
MsgBox("Failed to change color")
End IfCode:
If RichTextBox3.Find("[cr]") Then
RichTextBox3.ForeColor = Color.Red
End IfI'm using VS 2012