If varShort in VB.NET is a Short and varBit is a value from 0 to 15, how can I set the bit in varShort identified by varBit without disturbing any of the other bits in varShort?
My problem, of course, is with the most significant bit, bit 15. Since varBit is determined at runtime, the solution must work with any bit number.
You can use the bitshift operators, << and >>, to turn on the bit you want (and put this value in
varValue), and then bitwise OrvarShortandvarValueThere is information in this question about the bitshift operators in VB.NET