View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
ALEX ALEX is offline
external usenet poster
 
Posts: 493
Default Seems there is a bug with long integers in VBA

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