[RESOLVED] byte(1) to int16
Hi,
I'm reading in data over the serial port into a byte array, however the data I'm receiving is 16bit integers.
I need some help converting the byte array to to int16.
I remember doing something similar a couple years ago in C. I was reading in bytes over the serial port, and converting them to 32bit floats.
In C, I was able to declare a union, which was essentially a struct, except the contents of the union all shared the same memory space. So by declaring a 4-element byte array, I was able to write specific bytes into a float.
Is there anything similar to this in vb.net? or another way perhaps?
thanks,
ioll
edit:
nvm, i think I got it.
trying this...
Code:
Dim test() As Byte = {183, 55}
Dim test1 As Int16 =BitConverter.ToInt16(test, 0))