Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"OR" clause in an assignment

Status
Not open for further replies.

Programmer1974

Programmer
Joined
Feb 19, 2004
Messages
33
Location
US
I've seen this line of script in a few exampes here at teck tips, and I'm curious to what it's actually doing. Here is an example:

newAce.AccessMask = ADS_RIGHT_GENERIC_ALL Or DS_RIGHT_GENERIC_READ Or ADS_RIGHT_GENERIC_EXECUTE Or ADS_RIGHT_GENERIC_WRITE Or ADS_RIGHT_DELETE

You could also write a statement like this:

strTest = 1 OR 2

If you do this statement:

MsgBox strTest

The popup box will show the value "3". What in the world is the OR doing with these statements?

Thank you much!
 
Binary (also called bitwise) "OR"

1 = bin:0001
2 = bin:0010
OR (on each column eg "1" or "0" = "1") =
0011 = 3

Often used for stuffing multiple flags (as bits) into a single value, eg upsize_me = 1, with_fries = 2 --> upsize with fries = 3. When used this way, each option will be a power of 2, 1,2,4,8,16,32,.. .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top