Arindam Das Arindam Das - 4 months ago 19 Question

How do I split a 16-bit value into two 8-bit values in VB.NET?

I have a 16-bit value like this:


I want to split this in two 8-bit values like:

00000000 and 00000011

The 16-bit value is a variable,
, 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).