Link to home
Start Free TrialLog in
Avatar of smurray3
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
Avatar of bobbit31
bobbit31
Flag of United States of America image

if i understand you correctly, you have "search1 search2" in your textbox and you want to search your string for both search1 and search2...

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?

Avatar of smurray3
smurray3

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

yeah, not really :(
ASKER CERTIFIED SOLUTION
Avatar of Anthony Perkins
Anthony Perkins
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks, The link helped