bitwise operations

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
 
A

alantolan

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

NumericUpDown Control 2
[email protected] 1
String Methods 3
Menu Question 3
Status Bar 2
MenuItem35.PerformClick() 2
Reporting Tool 2
FontFamily.GetFamilies Method Question 1

Top