vba check if particular bits set in 64-bit longlong integer code example
Example 1: vba make long from two shorts
Public Function MakeLong&(ByVal LoWord%, ByVal HiWord%)
MakeLong = (HiWord * &H10000) Or (LoWord And &HFFFF&)
End Function
Example 2: vba low word from Long Integer
If n And &H8000& Then
LoWord = n Or &HFFFF0000
Else
LoWord = n And &HFFFF&
End If
HiWord = (n And &HFFFF0000) \ &H10000
Example 3: xl vba is specific bit set in longlong integer
Function LongLongBitIsSet(theLongLong^, bit As Byte) As Boolean
Static i&, b^()
If (Not Not b) = 0 Then
ReDim b(0 To 62)
For i = 0 To 62
b(i) = 2 ^ i
Next
End If
If bit < 63 Then LongLongBitIsSet = theLongLong And b(bit)
End Function
MsgBox LongBitIsSet(255, 7)
MsgBox LongBitIsSet(230, 0)
MsgBox LongBitIsSet(16384, 14)
MsgBox LongBitIsSet(-16383, 0)
MsgBox LongBitIsSet(&H7FFFFFFF, 0), 0)
MsgBox LongLongBitIsSet(&H7FFFFFFFFFFFFFff^, 62)