I have a VB.NET windows forms project. One of the values i am sending to a tool is a short value with a max of 2050. I need to be able to set the last bit of this short to either a 0 or a 1 based on some other criteria.
Need suggestions and / or pointers to how to do bit manipulation in VB.NET. Found lots of bit shifting but thats not what i need.
Cheers
Visual Basic.NET
Last Comment
Winston Smith
8/22/2022 - Mon
kaufmed
You can use the standard boolean operators (AND, OR, etc.) to do bit manipulation:
Sub Main() Dim test As Short = 0 Dim mask As Short = 1 << 2 test = test Or mask Console.WriteLine(test) Console.ReadKey() End Sub
Open in new window