Extracting the lower and upper byte of an integer
Sometimes, especially when dealing with the API, it can be useful to extract the lower and upper byte of an integer. VB doesn't support retreiving individual bytes of an integer in an easy manner, so we have to do bit masking and shifting to get it right:
Author:


Sub HiLoByte (ByVal Intg As Integer, LoByte As Integer, HiByte As Integer)

   LoByte = Intg And &HFF&
   HiByte = (Intg And &HFF00&) / 256

End Sub

Those using Visual Basic 4.0 or higher can replace
LoByte As Integer, HiByte As Integer
with
LoByte As Byte, HiByte As Byte
for more coherent operation.