INSTR statement question

  • Thread starter Thread starter David
  • Start date Start date
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")
 
InStr(1, txtCol, "Maint", vbBinaryCompare)

The start option is required when a compare option is specified.
 
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.
 
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,
 
Back
Top