Multiple = on one line

kahlua001

Well-known member
Joined
Dec 15, 2003
Messages
507
Location
los angeles
What are the multiple = doing here? Not as how it applies to the objects on this line, but when there are more than one = on a line, what is the logic of it?

checkBoxUnShift.Checked = (e.KeyState And 1) = 0 = False
 
When there is more than one equals comparison operator on a
single line, the values of each are evaluated from left to right.
So, in this (poor) example, first it would compare
(e.KeyState And 1) and 0. It takes this value and compares it to
False, and returns another boolean value (0 or 1).

Goodness knows why there are multiple =s on that line; the line
is checking to see if (e.KeyState And 1) is NOT equal to 0,
which the <> operator serves a purpose for:

Code:
checkBoxUnShift.Checked = (e.KeyState And 1) <> 0
 
Back
Top