string - Excel VBA instr if statement false -


i'm trying not value 2, "shouldn't happen" gets shown rather else, "ok".

if not instr("1, 2, 3", "2")     msgbox ("shouldn't happen") else     msgbox ("ok") end if 

we know value within string. yet reason "not" not working. know why?

thats because

?instr("1, 2, 3", "2")  4  

and

?not 4 -5 // bitwise not of 4 

which truthy value (cbool(-5) = true), instead need to:

if instr("1, 2, 3", "2") = 0   // not found else    // found 

Comments