Or (operator)

Syntax expression1 Or expression2
Description Performs a logical or binary disjunction on two expressions.
Comments If both expressions are either Boolean , Boolean variants, or Null variants, then a logical disjunction is performed as follows:
If the first expresionn is and the second expression is then: the result is
TRUE TRUE TRUE
TRUE FALSE TRUE
TRUE NULL TRUE
FALSE TRUE TRUE
FALSE FALSE FALSE
FALSE NULL NULL
NULL TRUE TRUE
NULL FALSE NULL
NULL NULL NULL
Binary Disjunction If the two expressions are Integer, then a binary disjunction is performed, returning an Integer result. All other numeric types (including Empty variants) are converted to Long and a binary disjunction is then performed, returning a Long result. Binary disjunction forms a new value based on a bit-by-bit comparison of the binary representations of the two expressions according to the following table:
1 Or 1 = 1 Example
0 Or 1 = 1 5  10101001
1 Or 0 = 1 6  01101010
0 Or 0 = 0 Or  11101011
Example 1 This first example shows the use of logical Or.
Sub Main()
  temperature_alert = True
  pressure_alert = False
  If temperature_alert Or pressure_alert Then
    MsgBox "You had better run!",ebExclamation,"Nuclear Disaster Imminent"
  End If
End Sub
Example 2 This second example shows the use of binary Or.
Sub Main()
  Dim w As Integer
TryAgain:
  s$ = InputBox("Enter a hex number (four digits max).","Binary Or Example")
  If Mid(s$,1,1) <> "&" Then
    s$ = "&H" & s$
  End If
  If Not IsNumeric(s$) Then Goto TryAgain
  w = Cint(s$)
  MsgBox "Your number is &H" & Hex(w)
  w = w Or &H8000
  MsgBox "Your number with the high bit set is &H" & Hex(w)
End Sub
See Also Operator Precedence (topic); Xor (operator); Eqv (operator); Imp (operator); And (operator).