This has no value as far as I’m concerned. I discovered this while researching a question.
In VBA:
Given the following: Dim a As Boolean, b As Boolean, c As Boolean
The code a = b = c = 1 = 1
Assigns a to False.
But a = b = c = true assigns a to true.
Can anyone explain why this is so? Obviously 1 = 1 evaluates to true.
As a side note, a = 1 = 1 will assign a to true as well. Also the behavior is the same using variants instead of Boolean values.
Again I know this has no practical purpose, I’m just curious if anyone can explain the behavior.
The expression is evaluated left to right because all the operators are of equal precedence.
b = c returns True.
True = 1 returns False because True converts to -1 prior to comparison.
False = 1 returns False
b = c returns True
True = true returns True.