Solved

problem wit Instr function

Posted on 2014-04-19
6
151 Views
Last Modified: 2014-04-19
If InStr(lbl1,lblCredit, "$") = True Then  this does not work
but this does;  If InStr(1, lblCredit, "$") Then
why?
0
Comment
Question by:isnoend2001
  • 4
  • 2
6 Comments
 
LVL 45

Expert Comment

by:Martin Liss
ID: 40010470
In the first one did you mean

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

or did you mean

InStr(1,lblCredit, "$") = True
0
 
LVL 45

Expert Comment

by:Martin Liss
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

by:isnoend2001
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 45

Accepted Solution

by:
Martin Liss earned 500 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

by:isnoend2001
ID: 40010484
thanks, learn something new everyday
0
 
LVL 45

Expert Comment

by:Martin Liss
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

708 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

15 Experts available now in Live!

Get 1:1 Help Now