When working with API functions, there is frequently a need to extract the low WORD (i.e. bits 0 to 15) or the high WORD (i.e. bits 16 to 31) from a DWORD (usually held in a VB Long variable). The sub below extracts both values and return them as Longs. If you need only one of these values, you can make a LoWord or HiWord function from the sub.
Public Sub SplitDword(ByVal Dword As Long, HiWord%, LoWord%)
HiWord = (Dword And (Not &HFFFF&)) \ &HFFFF&
LoWord = Dword And &HFFFF&
End Sub
No comments:
Post a Comment