Hello,
I'm trying to make a sub that will highlight the text of a RTB that is passed. Here is the code:
Private Sub SearchAll(ByVal selectedRichTextBox As RichTextBox)
Dim startPos As Int16 = 0
Dim matchPos As Integer = selectedRichTextBox.Find(TextBoxSearchFor.Text, startPos, selectedRichTextBox.Text.Length, RichTextBoxFinds.None)
selectedRichTextBox.SelectionBackColor = Color.Yellow
While matchPos >= 0
selectedRichTextBox.Select(matchPos, TextBoxSearchFor.Text.Length)
startPos = matchPos + TextBoxSearchFor.Text.Length
matchPos = selectedRichTextBox.Find(TextBoxSearchFor.Text, startPos, selectedRichTextBox.Text.Length, RichTextBoxFinds.None)
End While
MsgBox("You have finished searching!")
startPos = 0
End Sub
I've read acticles on this but I can't figure out what I'm doing wrong.
Awaiting for someone who could help me and thanks in advance,
Kappash