Re: bitwise operations

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



>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.

.



Relevant Pages