I have a 16-bit value like this:
0000000000000011
I want to split this in two 8-bit values like:
00000000 and 00000011
The 16-bit value is a variable, byte_val1
, which is a unsigned 16-bit integer.
How can I do this in VB.NET?
You can use the BitConverter
class:
Dim bytes As Byte() = BitConverter.GetBytes(byte_val1)
Now bytes(0)
contains the lower byte (00000011) and bytes(1)
contains the higher byte (00000000).