Try the following example for BitConverter to see if this works for you.
Sub Main()
Dim x32 As Int32 = &H432312AF
Dim a16, b16 As Int16 ' if you want 2 byte ints
Dim a32, b32 As Int32 ' if you want 4 byte ints
Dim ba As Byte() = BitConverter.GetBytes(x32)
a16 = BitConverter.ToInt16(ba, 0)
b16 = BitConverter.ToInt16(ba, 2)
a32 = a16 : b32 = b16
Console.Out.WriteLine(String.Format("{0:x} {1:x} {2:x}", x32, a32, b32))
Console.In.ReadLine()
End Sub
"Jack Jackson" <jj******@cinnovations.netwrote in message
news:st********************************@4ax.com...
What is the best way to sign extend a 16-bit value (such as half of
the lparam value in WM_NCxxx messages) into an Integer?
Currently I test for the 8000 bit and if set OR in FFFF0000, but it
seems like there should be some built-in way to do this.