problem wit Instr function

If InStr(lbl1,lblCredit, "$") = True Then  this does not work
but this does;  If InStr(1, lblCredit, "$") Then
Who is Participating?
Martin LissConnect With a Mentor Older than dirtCommented:
Let me restate what I said. In VB any non-zero value is 'True' but True itself is -1 so the position returned by InStr while non-zero and therefore True can never be = -1.
Martin LissOlder than dirtCommented:
In the first one did you mean

InStr(lbl1,lblCredit, "$") = True

or did you mean

InStr(1,lblCredit, "$") = True
Martin LissOlder than dirtCommented:
In any case InStr returns a position and since True is equal to -1, True will never be equal to the position.
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

isnoend2001Author Commented:
Whoops i meant
InStr(1,lblCredit, "$") = True does not work
this does
If InStr(1, lblCredit, "$") Then
using the = True causes it not to work
isnoend2001Author Commented:
thanks, learn something new everyday
Martin LissOlder than dirtCommented:
You're welcome and I'm glad I was able to help.

In my profile you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2014
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.