Dormire
0
Q:

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
8
'If n is a 4-byte Long Integer, the Low (Left) Word is:
If n And &H8000& Then
  	LoWord = n Or &HFFFF0000
Else
    LoWord = n And &HFFFF&
End If

'If n is a 4-byte Long Integer, the High (Right) Word is:
HiWord = (n And &HFFFF0000) \ &H10000
3
LoByte = n And &HFF					'<-- if n is a 2-byte Integer (left byte)
HiByte = (n And &HFF00&) \ &H100	'<-- if n is a 2-byte Integer (right byte)
4

New to Communities?

Join the community