Comparison is used to compare the contents of two variables against each
other.
!
Name
Description
Example
>
Greater Than
Expression1 is greater than and not equal to Expression2
boolRetVal =
objObject1 >
objObject2
<
Less Than
Expression1 is less than and not
equal to Expression2
boolRetVal =
objObject1 <
objObject2
<>
or ><
Not Equal
Expression1 is not equal to Expression2
boolRetVal =
objObject1 <>
objObject2
>= or =>
Greater Than or
Equal to
Expression1 is is greater than or
equal to Expression2
boolRetVal =
objObject1 >=
objObject2
<=
or =<
Less Than or Equal to
Expression1 is less than or equal to Expression2
boolRetVal =
objObject1 <=
objObject2
=
Equals
Expression1 is equal to
Expression2
boolRetVal =
objObject1 =
objObject2
IS
Is
Expression1 is Expression2 This comparison operator is used only against object variables. It
can compare one object against another, or an object against a condition.
boolRetVal =
objObject1 IS
objObject2
boolRetVal = objObject1 IS
Nothing
Logic operations are used to evaluate one or more expressions and return
logical values.
AND - logical conjunction
As a comparison operator: Returns True only if Expression1 and
Expression2 are true.
Comparison Examples: boolReturn = Expression1 AND
Expression2 If y = 15 AND
x < 23 Then
Expression1
Expression2
Result
True
True
False
False
True
False
True
False
True
False
False
False
As a bitwise operator: Compares the bits in both numeric expressions and
returns a value based on the following:
Expression1 Bit
Expression2 Bit
Result Bit
0
0
1
1
0
1
0
1
0
0
0
1
Essentially, the numeric values are evaluated at a binary level: (147) 10010011 (58) 00111010 (18) 00010010
So, with this example, 147
AND 58 =
18
OR - logical disjunction
As a comparison operator: Returns True if Expression1 or Expression2
are true, and if Expression1 and Expression2 are true.
Comparison Examples: boolReturn = Expression1 OR
Expression2 If y = 15 OR
x < 23 Then
Expression1
Expression2
Result
True
True
False
False
True
False
True
False
True
True
True
False
As a bitwise operator: Compares the bits in both numeric expressions
and returns a value based on the following:
Expression1 Bit
Expression2 Bit
Result Bit
0
0
1
1
0
1
0
1
0
1
1
1
Essentially, the numeric values are evaluated at a binary level: (147) 10010011 (58) 00111010
(187) 10111011
So, with this example, 147
OR 58 =
187
NOT - logical negation
As a comparison operator: Negates the Boolean value of Expression1
Expression1
Result
True
False
True
False
As a bitwise operator: Compares the bits in both numeric expressions
and returns a value based on the following:
Expression1 Bit
Result Bit
0
1
0
1
Essentially, the numeric values are evaluated at a binary level: (58) 00111010
(197) 11000101
So, with this example, NOT
58 = 197
Eqv - logical equivalence
As a comparison operator: Returns True only if Expression1 equals
Expression2
Comparison Examples: boolReturn = Expression1 Eqv
Expression2 If y = 15 Eqv
x < 23 Then
Expression1
Expression2
Result
True
True
False
False
True
False
True
False
True
False
False
True
As a bitwise operator: Compares the bits in both numeric expressions
and returns a value based on the following:
Expression1 Bit
Expression2 Bit
Result Bit
0
0
1
1
0
1
0
1
1
0
0
1
Essentially, the numeric values are evaluated at a binary level: (147) 10010011 (58) 00111010
(86) 01010110
So, with this example, 147
Eqv 58 =
86
Imp - logical implication
As a comparison operator: Returns based on table below
Comparison Examples: boolReturn = Expression1 Imp
Expression2 If y = 15 Imp
x < 23 Then
Expression1
Expression2
Result
True
True
True
False
False
False
Null
Null
Null
True
False
Null
True
False
Null
True
False
Null
True
False
Null
True
True
True
True
Null
Null
As a bitwise operator: Compares the bits in both numeric expressions
and returns a value based on the following:
Expression1 Bit
Expression2 Bit
Result Bit
0
0
1
1
0
1
0
1
1
1
0
1
Essentially, the numeric values are evaluated at a binary level: (147) 10010011 (58) 00111010
(126) 01111110
So, with this example, 147
Imp 58 =
126
Xor - logical exclusion
As a comparison operator: Returns based on table below
Comparison Examples: boolReturn = Expression1 Xor
Expression2 If y = 15 Xor
x < 23 Then
Expression1
Expression2
Result
True
True
True
False
False
False
Null
Null
Null
True
False
Null
True
False
Null
True
False
Null
False
True
Null
True
False
Null
Null
Null
Null
As a bitwise operator: Compares the bits in both numeric expressions
and returns a value based on the following:
Expression1 Bit
Expression2 Bit
Result Bit
0
0
1
1
0
1
0
1
0
1
1
0
Essentially, the numeric values are evaluated at a binary level: (147) 10010011 (58) 00111010
(169) 10101001
When evaluating a calculation line, the line is processed in the following
operator order, and within each operator class, in the order listed. When
evaluating a line, multiple identical operators are processed from left to
right.
Order
Category
Precedence
1
Arithmetic
^, (/ *), \, MOD, (+ -)
2
Concatenation
(& +)
3
Comparison
(No defined order, as listed from left to right)
4
Logical
Not, And, Or, Xor,
Eqv, Imp
If you need to override any given precedence, you place the single
calculation element within parenthesis.
As an example of how operator precedence works, copy/paste this code snippet
into notepad, save it and run it to see how the totals differ: Change the
uncommented line to see the different calculations.