[SOLVED]
VB.NET: Problem: Trying to change the color of more than one of the same text within a RichTextBox. I found that I was able to achieve this by using the following code:
CODE
Dim int1 As Integer = 0
Dim search1 As String = "Boat"
While int1 <> -1
int1 = RichTextBox1.Text.IndexOf(search1, int1)
If int1 <> -1 Then
RichTextBox1.SelectionStart = int1
RichTextBox1.SelectionLength = search1.Length
RichTextBox1.SelectionColor = Color.Blue
int1 = int1 + search1.Length
End If
End While
The above code searches for, and changes the color of all "Boat"s found in the RichTextBox.
There are a few problems, such as: If you were to go back to edit the RichTextBox and place your cursor in front of the, now blue word, "Boat" and type then all of your text would be blue.
Also, the text you wish to change the color of in the RichTextBox MUST be Exactly the same as: "Search1", aka "Boat", capital letters and all.
This post has been edited by JohnorSky: 10 Apr, 2009 - 06:04 PM