smurray3
asked on
Search for 2 words at once
I currently search for a specific string that is being populated in a textbox. I would like to be able to provide two key words to look for when the serial data is being read. So if one comment is there and one is not it could parse the data and continue.
Here is my search for one word below.
Thanks
Dim hFind As String
Dim hString As String
Dim hCounter As Long
Dim hSearch As String
hFind = False
Do While hFind = False
hSearch = Mid$(line_command$, 6)
hCounter = InStr(Term.Text, hSearch)
If hCounter Then
Term.SelStart = hCounter - 1
Term.SelLength = Len(hSearch)
Term.SelText = ""
hFind = True
hSearch = Mid$(line_command$, 6)
hString = hSearch
hCounter = InStr(Term.Text, hSearch)
Do While hFind = False
DoEvents ' Yield to other processes.
Loop
Exit Do
End If
DoEvents
If Timer - lStartTime > 15 Then
Term.BackColor = &HFF&
Local_flag = False
Global_flag = False
Fail_Command$ = line_command$
FrmMain.StatusBar.Panels(2 ).Text = "Verification Failure trying to verify " + hSearch
Exit Do
End If
Loop
Here is my search for one word below.
Thanks
Dim hFind As String
Dim hString As String
Dim hCounter As Long
Dim hSearch As String
hFind = False
Do While hFind = False
hSearch = Mid$(line_command$, 6)
hCounter = InStr(Term.Text, hSearch)
If hCounter Then
Term.SelStart = hCounter - 1
Term.SelLength = Len(hSearch)
Term.SelText = ""
hFind = True
hSearch = Mid$(line_command$, 6)
hString = hSearch
hCounter = InStr(Term.Text, hSearch)
Do While hFind = False
DoEvents ' Yield to other processes.
Loop
Exit Do
End If
DoEvents
If Timer - lStartTime > 15 Then
Term.BackColor = &HFF&
Local_flag = False
Global_flag = False
Fail_Command$ = line_command$
FrmMain.StatusBar.Panels(2
Exit Do
End If
Loop
ASKER
I currently have just one search routine in that mess of code. I would however like to be able to hardcode a search string. Say if something like "new user" was feed in while I was searching for "Tom" I could process the new user and then the other.
Hope this makes sense
Hope this makes sense
> Hope this makes sense
yeah, not really :(
yeah, not really :(
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks, The link helped
Dim search() as string
search = split(text1.text, " ")
then do something like
for i = 0 to UBound(search)
'' do your search routine
next
is that what you want?