Seems there is a bug with long integers in VBA
Thank you!
"Peter T" wrote:
Try this -
Debug.Print &HFFFF, &HFFFF& ' -1 65535
Regards,
Peter T
"Alex" wrote in message
...
Hi everybody,
I tried assign values using hexidecimal notation in Excel 2003 SP2
and found that &hFFFF is not equal to &h10000 - 1 for LONG integers.
Sample is he
Sub test()
Const WorkaroundValue As Long = &H10000 - 1
Const WrongValue As Long = &HFFFF
Dim lVal As Long
lVal = &HFFFF
Debug.Print "lVal: " & lVal & " " & Hex(lVal)
If WorkaroundValue = WrongValue Then
Debug.Print "Equal"
Else
Debug.Print "Not Equal: " & WorkaroundValue & "," & WrongValue
Debug.Print "In hex: " & Hex(WorkaroundValue) & "," &
Hex(WrongValue)
End If
End Sub
Cheers,
Alex
|