Solved

Search for 2 words at once

Posted on 2002-03-12
5
120 Views
Last Modified: 2010-05-02
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
0
Comment
Question by:smurray3
  • 2
  • 2
5 Comments
 
LVL 18

Expert Comment

by:bobbit31
Comment Utility
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?

0
 

Author Comment

by:smurray3
Comment Utility
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
0
 
LVL 18

Expert Comment

by:bobbit31
Comment Utility
> Hope this makes sense

yeah, not really :(
0
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 250 total points
Comment Utility
This is trivial with the VBScript Regular Expression library.  Take a look at this link:

http://www.vb2themax.com/Item.asp?PageID=TipBank&ID=402

Anthony
0
 

Author Comment

by:smurray3
Comment Utility
Thanks, The link helped
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now