I've managed to put together the code to find and hightlight a word in a richtextbox, but it will only do it once. I need to find, and highlight, all instances of the word, and I'm getting nowhere fast. What modifications do I need to make to this?
Code:
Dim strWord As String
Dim lPos As Long
strWord = "Hello"
lPos = InStr(1, RichTextBox1.Text, strWord, vbTextCompare)
If lPos > 0 Then
With RichTextBox1
.SelStart = lPos - 1
.SelLength = Len(strWord)
.SelColor = vbRed
.SelBold = True
.SelStart = Len(RichTextBox1.Text)
End With
End If