If you read my Not, And, Or, Xor, Imp, Eqv, and Null. Oh, my! post, you'll know that the canonical value for False in VB6 is zero, and the canonical value for True is -1.
So, how can the comparison bellow prints True?
Debug.Print True = "1"
When dealing with different data types, VB6 employs implicit conversion.
I don't have access to VB6's source code, but it seems these are its rules when dealing with Boolean and String:
- If the string is "True" irrespective of its case, then convert it to boolean True.
- If the string is "False" irrespective of its case, then convert it to boolean False.
- If the string is not "True" or "False", then convert it to Double.
- If the converted value is zero, then convert it to boolean False, otherwise, convert it to boolean True.
- Any leading or trailing tabs or spaces are ignored.
- It understands numbers in octal, hexa, or scientific notations.
- It uses the system's decimal and thousands separators.
- If the string is not convertible, then an error is raised (13: type mismatch)
- If the converted value would exceed Double's limits, then an error is raised (6: overflow)
Now, keeping these rules in mind, can you explain why all comparison below prints "True"?
Debug.Print True = "0.1"
Debug.Print True = "0,1"
Debug.Print False = "0.0"
Debug.Print False = "0,0"