VBScript » Operators » Or

Version: 1.0

The Or operator is used to perform a logical disjunction on two expressions, where the expressions are Null, or are of Boolean subtype and have a value of True or False.

The Or operator can also be used a "bitwise operator" to make a bit-by-bit comparison of two integers. If one or both bits in the comparison are 1, then a 1 is returned. Otherwise, a 0 is returned.

Examples

Code:
<% =True Or True %>
<% =True Or False %>
<% =False Or True %>
<% =False Or False %>

<% =True Or Null %>
<% =Null Or True %>
<% =False Or Null %>
<% =Null Or False %>
<% =Null Or Null %>
Output:
True
True
True
False
True
True
(Null output)
(Null output)
(Null output)
Explanation:

When using the Or to compare Boolean expressions, the order of the expressions is important.

Language(s): VBScript
Code:
<%
Expression1 = 1
Expression2 = 2
Result = Expression1 Or Expression2
Response.Write "Result = " Result
%>
Output:
Result = 3
Explanation:

In this example, the Or performs a bitwise comparison on the 1 (in binary 001) and the 2 (in binary 010), and returns a 3 (in binary 011).

Language(s): VBScript

See Also: