dragon4spy
09-05-2003, 06:24 AM
I'd like to get the low word of a long datatype. Let's say L is the long data type, and L=&hFFFFFFFF (max value of long). I've tried L AND &hFFFF to get the low word but it's fail. The result is not the extracted Word, but the same value of L.
Normally, it works fine with integer and byte datatype. Anyone got some idea?
Thanks in advance
Iceplug
09-05-2003, 06:27 AM
Try
L And &HFFFF&
without the &, &HFFFF is interpreted as an integer... and thus the AND operation will not work as you want it to. :)
00100b
09-05-2003, 06:28 AM
Private Declare Sub CopyMemory Lib "kernel32" _
Alias "RtlMoveMemory" (pDest As Any, pSource As Any, _
ByVal ByteLen As Long)
Public Function HiWord(ByVal dw As Long) As Integer
CopyMemory HiWord, ByVal VarPtr(dw) + 2, 2&
End Function
Public Function LoWord(ByVal dw As Long) As Integer
CopyMemory LoWord, dw, 2&
End Function
dragon4spy
09-05-2003, 06:32 AM
Wow! thanks 4 promptly answers. ;-D