Kevin_Elrod
asked on
Bit manipulation in VB
I am a C++ programmer now learning VB. Is it possible to do bit manipulation in VB? I need to call functions in the Win32 API, as well as from my own dll's, that return values that require bit manipulation.
There are not any shift operators, but when you shift the bits one position to the left, you are really multiplying by 2. When you shift right, you are dividing by 2.
THe VB operators AND and OR are the LOGICAL equivalents of the C++ operators && and ||
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>THe VB operators AND and OR are the LOGICAL equivalents of the C++ operators && and ||
Actually they're always bit-wise in VB, so they're equivalent to & and |. True is -1, so all bits are set. All numbers are signed in VB.
You've also got Xor, and Not (of course), but unfortunately there isn't a shift or rotate.
Actually they're always bit-wise in VB, so they're equivalent to & and |. True is -1, so all bits are set. All numbers are signed in VB.
You've also got Xor, and Not (of course), but unfortunately there isn't a shift or rotate.
For example:
Dim Flags As Long
Flags = &H1A&
Flags = Flags AND &HF&
MsgBox Hex(Flags) '<-- Displays ' A '
Flags = Flags OR 1
MsgBox Hex(Flags) '<-- Displays ' B '