Try thisVB Code:
Option Explicit Dim lStart As Long Dim lEnd As Long Dim Found As String Private Function FindNext(lStart As Long, lEnd As Long, Found As String) As Boolean FindNext = False If lStart = 0 Then lStart = -1 lStart = RTB.Find("*", lStart + 1) If lStart < 0 Then Exit Function lEnd = InStr(lStart + 1, RTB.Text, vbCrLf) Found = Mid(RTB.Text, lStart + 1, lEnd - lStart - 1) FindNext = True End Function Private Sub Command1_Click() If Not FindNext(lStart, lEnd, Found) Then MsgBox "All Words Found" Else 'do your highlighting here MsgBox "Found: " & Found End If End Sub Private Sub Form_Load() RTB.SelText = "This is a test" & vbCrLf RTB.SelText = "*Find" & vbCrLf RTB.SelText = "Don't Find" & vbCrLf RTB.SelText = "*Hello" & vbCrLf RTB.SelText = "*There" & vbCrLf RTB.SelText = "Skip me" & vbCrLf RTB.SelText = "*Get" & vbCrLf End Sub




Reply With Quote