Winston Smith
asked on
How to set a bit in a short value
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
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
I meant to say "logic", not "boolean" :)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hold on.
'Clear the bit (if positive)
s = CType(s And 32766, Short)
'Clear the bit (if positive)
s = CType(s And 32766, Short)
ASKER
Worked great, cheers!
Open in new window