Link to home
Start Free TrialLog in
Avatar of PeterBaileyUk
PeterBaileyUk

asked on

How do I test if bit 128 is set? in vb

I would like a function that tell me if bit 128 is set in any number that I pass to the function, in vb not sure how.
Avatar of oleggold
oleggold
Flag of United States of America image

try this:
http://forums.realbasic.com/viewtopic.php?t=8124
dim CRC as bytedim CRCDATA as bytedim CRCbit0 as bytedim CRCDATAbit0 as bytedim I as bytedim TestBit as byteCRC=0CRCDATA=40  'inputFor I = 0 to 7 ' Do for all 8 bits in data byte  CRCBit0 = Bitwise.BitAnd( CRC, &b1 )  CRCDATAbit0=Bitwise.BitAnd( CRCDATA, &b1 )  TestBit = Bitwise.BitXor( CRCBit0, CRCDataBit0 )' XOR bit0 of data byte and crc  CRCData = Bitwise.ShiftRight( CRCData, 1 ) ' Position data byte for next bit test  If TestBit = 0  then goto Shift ' If test bit not set, just shift CRC  CRC = Bitwise.BitXor( CRC, 24 ) ' If set, account for EXOR feedback $18=24dec  Shift: ' Shift right the CRC byte  CRC = Bitwise.ShiftRight( CRC, 1 ) ' CRC bit 0 to bit bucket  if TestBit=1 then    CRC = Bitwise.BitOr( CRC,128)  END IFNext I Test bit rotates into CRC bit 7Next I

Open in new window

Avatar of PeterBaileyUk
PeterBaileyUk

ASKER

I should have mentioned that it is for use in an sql query grid, not sure if access 2007 will allow it.
Avatar of GrahamSkan
Do you mean bit 128 or the bit for value 128 (i.e. bit 8)

if l AND 128 then
 bit8 = true
end if
ASKER CERTIFIED SOLUTION
Avatar of GrahamSkan
GrahamSkan
Flag of United Kingdom of Great Britain and Northern Ireland 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