INSTR statement question

D

David

Is there a way to get this function to ignore case. i.e. I
want to find

INSTR(txtCol,"Maint")

and

INSTR(txtCol,"maint")
 
W

Wayne Morgan

InStr(1, txtCol, "Maint", vbBinaryCompare)

The start option is required when a compare option is specified.
 
C

Cheryl Fischer

You could use InStr() with its Compare argument:

InStr(1, txtCol, "maint", vbTextCompare)

Also, I'd suggest checking out the Option Compare statement in VBA Help.
When set at module level, it will determine the default comparison method to
use for comparing strings so that you do not have to set/reset this option.
 
C

Cheryl Fischer

Just to make sure that I have interpreted your question correctly ...

In: InStr(1, txtCol, "maint", vbTextCompare) "maint" and "Maint" are
considered equal. So, if the value of your control, txtCol, is: 123Maint,
the expression above will return 4.

In: InStr(1, txtCol, "maint", vbBinaryCompare) "maint" and "Maint" are
not equal. if the value of your control, txtCol, is: 123Maint, the
expression above will return 0.

hth,
 

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