I'm trying to create a text search, note that all variables are defined even if they aren't listed here
if i type for example "hi hi hi hi hi" then click search it will find and highlight the first one, then i click it again and it finds the second, then when i click it again it finds the second again any help?
here is the code:
mail me at [email protected] if you need more specifics but can help meCode:Dim searched, newsearch As Long
Private Sub cmdSearch_Click()
searchtext = txtSearch.Text
newsearch = searchpos + Len(searchtext)
If searched = 0 Then searchpos = InStr(frmMain.txtNotepad.Text, frmSearch.txtSearch.Text)
If searched = 1 Then searchpos = InStr(newsearch, frmMain.txtNotepad.Text, frmSearch.txtSearch.Text)
If searchpos > 0 Then
frmMain.txtNotepad.SetFocus
searchlen = Len(searchtext)
frmMain.txtNotepad.SelStart = searchpos - 1
frmMain.txtNotepad.SelLength = searchlen
End If
searched = 1
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
Select Case UnloadMode
Case vbFormControlMenu
searched = 0
End Select
End Sub
