How do I make InStr case sensitive in MS Access?
I'd like the following to display 0
msgbox InStr("In Here", "here")
Instead I get 4
.
I've tried adding vbBinaryCompare
msgbox InStr("In Here", "here", vbBinaryCompare)
but it complains about a type mismatch.
INSTR is case-sensitive. Use one of the case-conversion functions to locate both uppercase and lowercase instances of a letter or character string.
Use InStrB
instead of InStr
. Then it will do a byte by byte comparison instead of case insensitive.
msgbox InStrB("In Here", "here")
Displays 0
.
The help topic doesn't make this point clear, but when you use the optional compare argument, you need to also supply the optional start argument in order to avoid that type mismatch complaint.
So this displays 0 in the MsgBox
:
MsgBox InStr(1,"In Here", "here", vbBinaryCompare)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With