Justin
Justin

Reputation: 473

VB Convert 3 bytes into an Int32 variable

I searched similar solutions as: Converting 3 bytes into signed integer in C#

There are something different in VB.net. But, I am asking for the equivalent code.

Correct me if I am wrong: (1) VB.net does no accept things like :

b0 << 24 

it only does

b0 = b0 << 24

(2) For code of

r |= b1 << 16 ' This is in C#

Which operation is done first, << or |=?

(3) Referring to the linked thread, how to do

b0 = 0xff 

in Vb.net?

Many thanks for giving help on the above 3 Qs.

Upvotes: 0

Views: 90

Answers (1)

ib11
ib11

Reputation: 2568

(1) Yes, in VB you need to provide the variable first that you want to change the value of:

b0 = b0 << 24

(2) The << is done first, but this is C#. In VB you don't have |= assignment operator. This is in C# and x |= y means the same as x = x | y and means the same as

x = x OR y

You need to use the last in VB as you do not have | or |= in VB.

(3) Not sure on what you mean here. But if you are asking on how to dimension the byte variable and assign the maximum value to it, you would use this:

Dim b0 As Byte = 255

Upvotes: 1

Related Questions