Solved

Search for 2 words at once

Posted on 2002-03-12
5
132 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 18

Expert Comment

by:bobbit31
ID: 6858006
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
ID: 6858036
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
ID: 6858874
> Hope this makes sense

yeah, not really :(
0
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 250 total points
ID: 6858954
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
ID: 6864747
Thanks, The link helped
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month11 days, 6 hours left to enroll

631 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