|
-
Mar 6th, 2002, 10:37 AM
#1
Thread Starter
Fanatic Member
Bit OR ???
Hi all,
I am using the common dialog control to display the print dialog box...
When this returns I need to check what teh user selected.. eg Collate, PrintToFile, PrintSelection..
I know these are set in the Common dialogs Flag property, but they are all stored in a single number...
In VB how can UI check which bits are set?
Leather Face is comin...
MCSD
-
Mar 6th, 2002, 10:46 AM
#2
to set them you use something like:
flags = a OR b OR c
to check them you do:
if (flags AND a) = a then ...
-
Mar 6th, 2002, 10:50 AM
#3
Fanatic Member
You can use this code to convert a byte from decimal to binary:
VB Code:
Public Function CBin(ByVal b As Byte) As String
Dim i As Long
For i = 7 To 0 Step -1
If 2 ^ i <= b Then
CBin = CBin & "1"
b = b - 2 ^ i
Else
CBin = CBin & "0"
End If
Next i
End Function
Just change the "7" to "30" for longs and "14" for integers (as well as the datatype of "b").
After you use that code on a regular decimal number, you will see a binary number. Each of the 1's and 0's in this binary number can be a flag. When you do this: you get 1010, which is combining those flags. To test if your four-digit binary number has this flag set: 0010, do this:
VB Code:
If (XXXX AND 0010) Then Debug.Print "XXXX has flag 0010 set"
-
Mar 7th, 2002, 07:29 AM
#4
Thread Starter
Fanatic Member
-
Mar 7th, 2002, 11:20 PM
#5
Fanatic Member
It's Victor-- I'm a guy ;P
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|