How use bit fields in VB? 
Author Message
 How use bit fields in VB?

Using VB6 enterprise

I have a long variable which I need to be able to set/test whether individual bits are set or not!

I can't see an obvious way with VB!

Any ideas

Thanks

Adrian Harrison



Fri, 07 Sep 2001 03:00:00 GMT  
 How use bit fields in VB?
Use the AND keyword.  In VB all ANDs/ORs are bitwise.  Thus;
Dim rc As Long
rc = 5 AND 3    '101 and 011 = 001
Debug.Print rc  'gives 1
--
Karl Westberg, MCP

Quote:

>Using VB6 enterprise

>I have a long variable which I need to be able to set/test whether

individual bits are set or not!
Quote:

>I can't see an obvious way with VB!

>Any ideas

>Thanks

>Adrian Harrison



Fri, 07 Sep 2001 03:00:00 GMT  
 How use bit fields in VB?
You can use the "And" operator with values like 1, 2, 4, 8, 16, 32, 64, . .
. to check each bit.

x=65
?x and 64
64
?x and 2
0

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~ Neal R. Champion
~ Gandalf Development, Inc.   Computing Solutions
~ Phone: 205-824-0056   Fax: 205-849-1068   Pager: 800-895-2684
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Quote:
> Using VB6 enterprise

> I have a long variable which I need to be able to set/test whether

individual bits are set or not!
Quote:

> I can't see an obvious way with VB!

> Any ideas

> Thanks

> Adrian Harrison



Fri, 07 Sep 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Printing Database field Problem in CR 6.0 (16-bit) using VB 3.0

2. Compiling a 16-bit executable using 32-bit VB.

3. Using 16-bit dll's in 32-bit VB

4. Moving field data between fields using VB 6 exe

5. Help, urgent: compiling 16 bit vb 4 coe to 32 bit vb 4 code

6. 16 bit API calls in VB 3 supported in 32 bit VB 4.0

7. How use bit fields in VB?

8. Need help manipulating Bit Fields in VB

9. Need help manipulating Bit Fields in VB

10. Need help manipulating Bit Fields in VB

11. Unions and bit fields in VB

12. Using both 16 bit and 32 bit FindWindow declares

 

 
Powered by phpBB® Forum Software