InStr Function

J

JohnV

I have a text field that users can enter some query
criteria into. The criteria will end up being in the
forms listed below:
0101,0301
0205, 0107, 0406
0101 or 0301 0108
0103or0203

The numeric values are the criteria and it can range from
1 to 15 criteria. I am trying to use the inStr function
to determine if the delimeter is a "," or the word "or".
If the position returned is 0 then I know there is only 1
search criteria, if > 0 then I know there are many
criteria. For some reason the following code does not
find the position:

dim strTemp as string, intFound as Integer
strTEMP = "0101 or 0301"
strSearch = "or"
intFound = InStr(1, strSearch, strTEMP, 1)
strTEMP = "0101,0301"
strSearch = ","
intFound = InStr(1, strSearch, strTEMP, 1)

I have looked in the help files and through my books and
this should work. Obviously, I am missing something but
can't figure out what.

I have some work arounds, but I really hate not knowing
why the code doesn't work.

Any help would be appreciated.
 
J

Jen

Looks like you have your strings reversed, should be:

intFound = InStr(1,strTEMP, strSearch, 1)

Regards,
Jen
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top