I'm sure that I'm missing something really simple here, but I'm a little bit confused about how I can get some Boolean results out of something like an INSTR.
Here is an example of what I am trying to do...
Suppose I have a string that I set like this:
a$ = "hello world"
Now I run this code:
If InStr(a$, "world") Then
Print "The word world was present in the string"
End If
In that case the message will be printed because InStr evaluates to TRUE since "world" is present in the string.
Now, suppose I want to take an action if "WORLD" is in the string AND "hello" is NOT in the string.
Here is how I tried to structure this:
If (InStr(a$, "world")) AND (NOT (InStr(a$,"hello"))) Then
Print "The word world was present and hello was not"
End If
I would expect that to fail because both "hello" and "world" are present and yet the message is still displayed.
I realize that I could perform 2 seperate operations, 1 to check for the presence of "world" and another to check for "hello" but I wanted to see if this could be one on a single line.
I realize that INSTR does not return a simple TRUE or FALSE, rather, it returns the position the string sought, which would be 0 if not present, but isn't there some simple way to convert that into a simple TRUE or FALSE?
Any thoughts on this?