bitwise operations

  • Thread starter Thread starter S Shulman
  • Start date Start date
S

S Shulman

Hi

I am looking for a sample of code that sets and reads individual bits within
an Integer

Thank you,
Shmuel Shulman
SBS Technologies LTD
 
I am looking for a sample of code that sets and reads individual bits within an Integer

The AND, OR and NOT operators are used for both logical and bitwise
operations in VB.

To turn a specific bit on, use OR

&H1000 OR &H0001 = &H1001

To turn a specfic bit off, use AND and NOT

&H1001 AND NOT &H0001 = &H1000

To ascertain if a specific bit is turned on, use AND and check the
result against 0

&H1000 AND &H0001 = &H0000 => not on
&H1001 AND &H0001 = &H0001 => is on.


hth,
Alan.
 
Back
Top