VB Code:
Public Sub UnderlineText(objRTB As Object, strFind As String)
'=============================================================
Dim intPos As Integer, i As Integer
With objRTB
For i = 1 To Len(.Text)
If intPos = 0 Then
intPos = InStr(1, LCase(objRTB.Text), LCase(strFind))
ElseIf intPos > 0 Then
intPos = InStr(intPos + Len(strFind), LCase(objRTB.Text), LCase(strFind))
End If
If Not intPos = -1 Then
If Not intPos = 0 Then .SelStart = intPos - 1
.SelLength = Len(strFind)
.SelBold = True
.SelUnderline = True
End If
Next i
End With
End Sub
'usage:
Private Sub Command1_Click()
'============================
Dim strFind As String
strFind = InputBox("Find Text To Highlight", "Find Text", "text")
UnderlineText RichTextBox1, LCase(strFind)
End Sub