excel-vba make a short integer from two byte values code example
Example 1: excel vba make a short integer from two bytes
Public Function MakeInteger%(LoByte As Byte, HiByte As Byte)
If HiByte And &H80 Then
MakeInteger = ((HiByte * &H100&) Or LoByte) Or &HFFFF0000
Else
MakeInteger = (HiByte * &H100) Or LoByte
End If
End Function
Example 2: excel vba last byte from INTEGER
LoByte = n And &HFF
HiByte = (n And &HFF00&) \ &H100
Example 3: excel vba high 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