Link to home
Start Free TrialLog in
Avatar of lbowers
lbowersFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Bit shifting...

What's the best method of bit shifting in VB6?
I'm unable to find any methods to do the job so assume a bit of work is required. I need to be able to shift the bits by a set amount.
Thanks in advance.
Avatar of VBGuru
VBGuru
Flag of India image

for bit wise operation use And Operator
Eqv,imp, Not,Or,Xor operators as below. Use the same to implement the shift
MyCheck = A And B
Avatar of mark2150
mark2150

Don't forget integer divide \

AND won't *shift* bits. You've got to declare 'em integers and multiply by 2/4/8, etc. to implement shift lefts and you can do integer divide by 2/4/8 etc. for shift right.

M

Avatar of lbowers

ASKER

AND doesn't shift - It just selectively removes bits.
Thanks anyway.
ASKER CERTIFIED SOLUTION
Avatar of viktornet
viktornet
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
opps ;-))

sorry, the line that reads..

bit(1)=1:bit(2)=2:bit(3)=4:bit(4)=8:bit(5)=16:bit(6)=32:bit(7)=64:bit(8)=128

should be replaced with the following :)

bit(1)=2:bit(2)=4:bit(3)=8:bit(4)=16:bit(5)=32:bit(6)=64:bit(7)=128:bit(8)=256

sorry for the inconvenience.. ;-)

..-=ViKtOr=-..