Most valuable professional
  • Hot Topics

Excel Bit Manipulation using VBA

I have a variable called ReadIO that reads the value of an Input output module. The decimal value for ReadIO ranges from 0 to 255 representing and 8 digit binary number i.e. 1 1 1 1 1 1 0 1 is decimal 253 Is there any known vba code that I can use to take the value from the variable Read IO then determine what the decimal value should be if I want to turn on or off an individual bit? For example suppose the value for ReadIO is 63 corresponding to binary 0 0 1 1 1 1 1 1 I want to create code to take that value (whatever it is 63 is just an example) and choose to change the value of bit 4 to a low state i.e. 0 Therefore the binary code will change to 0 0 1 1 0 1 1 1 or decimal 55 I imagine this is routine code that must exist somewhere in vb

This question generated 17 answers. To proceed to the answers, click here.

This thread is current as of April 9, 2015.

For more resources for Microsoft Excel:

This article includes the following tags:

  • Excel
  • Microsoft Excel