VB.NET - How To Search And Highlight Text In A RichTextBox Using Visual Basic.NET
In This VB.NET Tutorial We Will See How To Search And Highlight Text In A RichTextBox
Using Visual Basic .NET Programming Language .
Project Source Code:
Public Class VBNET_Text_Search
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim startText As Integer = 0
Dim endText As Integer
endText = RichTextBox1.Text.LastIndexOf(TextBox1.Text)
RichTextBox1.SelectAll()
RichTextBox1.SelectionBackColor = Color.White
While startText < endText
RichTextBox1.Find(TextBox1.Text, startText, RichTextBox1.TextLength, RichTextBoxFinds.MatchCase)
RichTextBox1.SelectionBackColor = Color.Brown
startText = RichTextBox1.Text.IndexOf(TextBox1.Text, startText) + 1
End While
End Sub
End Class
2 comments
commentsgood jobs! Thanks man
ReplyGreat! Thank you
Reply