Code:
Dim srch4 As String = "how"
TextBox1.Text = "Hello, how are you?"
Dim id As Integer = TextBox1.Text.IndexOf(srch4)
If id <> -1 Then
TextBox1.Select() 'set focus to control
TextBox1.Select(id, srch.Length)
End If
RichTextBox2.Text = RichTextBox2.Text.Insert(0, "ABhowCDEFGHIJKLMNOPQRSTUVWXYZ") 'insert text at beginning
id = RichTextBox2.Text.IndexOf(srch4)
If id <> -1 Then
RichTextBox2.Select() '<<<<<<<<<<<<<<<<<<<<< make sure the control has focus
RichTextBox2.Select(id, srch4.Length) 'start and end according to index of text
RichTextBox2.SelectionColor = Color.Blue
Dim FontStyle1 As System.Drawing.FontStyle
FontStyle1 = CType((FontStyle.Underline + FontStyle.Bold), FontStyle)
RichTextBox2.SelectionFont = New Font(RichTextBox2.SelectionFont.FontFamily, RichTextBox2.SelectionFont.Size, FontStyle1)
End If