Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
Solved

# problem wit Instr function

Posted on 2014-04-19
Medium Priority
161 Views
If InStr(lbl1,lblCredit, "\$") = True Then  this does not work
but this does;  If InStr(1, lblCredit, "\$") Then
why?
0
Question by:isnoend2001
[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
• 4
• 2

LVL 49

Expert Comment

ID: 40010470
In the first one did you mean

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

or did you mean

InStr(1,lblCredit, "\$") = True
0

LVL 49

Expert Comment

ID: 40010477
In any case InStr returns a position and since True is equal to -1, True will never be equal to the position.
0

Author Comment

ID: 40010479
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
0

LVL 49

Accepted Solution

Martin Liss earned 2000 total points
ID: 40010481
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.
0

Author Closing Comment

ID: 40010484
thanks, learn something new everyday
0

LVL 49

Expert Comment

ID: 40010489
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
0

## Featured Post

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 …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
###### Suggested Courses
Course of the Month11 days, 2 hours left to enroll