strongm, I sort of agree, yet sort of not. InStr is not Boolean. The value is 0 (or not). We interpret - as you state, from one perspective - that 0 as False.
Code:
Dim strIn As String
Dim bolWhatever As Boolean
strIn = "Badda bing, badda boom"
MsgBox InStr(1, strIn, "yadda") & vbCrLf _
& bolWhatever
will display:
0
False
On the other hand, you are absolutely correct in stating that "true", is anything
other than 0.
Code:
Dim bolWhatever As Boolean
Dim j As Long
j = 2317826
bolWhatever = j
Msgbox "bolWhatever set as " & j & vbCrLf _
& bolWhatever
will display:
bolWhatever set as 2317826
True
HOWEVER, the only way to get the number is to use a number variable (in this case, j), and display THAT.
Code:
Dim bolWhatever As Boolean
bolWhatever = 2317826
As a boolean, you can
give it a number - 2317826 for example - but you can never
get that number. bolWhatever does not equal 2317826 (even with the statement bolWhatever = 2317826). It = True. Or as you put it correctly "Not 0".
Code:
bolWhatever = 2317826
If bolWhatever = 2317826 Then
MsgBox "Worked."
Else
MsgBox "Not worked"
End If
will always return "Not worked", no matter what number you make bolWhatever equal. You can give a true boolean variable any number you want, but it will never keep it. bolWhatever does not
really = 2317826, even if there is an explicit instruction. It = Not 0, or True. You can not even get a 0 value from a true boolean. You get "False". You can use 0 in a logic statement:
If bolWhatever = 0
but you can never GET a 0 from a boolean.
bolWhatever = 0
Debug.Print bolWhatever
will not display 0, it displays False.
InStr though is a Long, not a Boolean. So yes, we humans
interpret Instr(0) as False, but it really means .....0
The point being is that 0 does not really mean "False".
It could mean THREE possible things:
string1 is zero-length
string2 is not found (your False)
start > string2
In other words, suppose you accidentally gave a Start greater than that a TRUE found.....
strWhatever = "This is a big sentence."
InStr(13, strWhatever, "big")
will return a 0. Even though, it is TRUE, that "big" really is in the given string.
So yes we
interpret InStr(0) as "False", and it probably does mean that, it does not really mean False. It means....0
faq219-2884
Gerry
My paintings and sculpture