Sub Test()
Dim iX As Integer
iX = 1 = 1
'Out put is -1
MsgBox iX
End Sub
1 Answer
Because if you compare 1 with a 1 this is True so 1 = 1 is True and True is considered as -1 in VBA by definition and you write this result into your variable iX.
This iX = 1 = 1 is evaluated the same as iX = (1 = 1) and this is iX = True and since iX is Integer the True is converted into a numeric value -1.
By definition in VBA:
Trueis-1Falseis0
But in Excel formulas
Trueis1Falseis0