Microsoft® Visual Basic® Scripting Edition
Comparison Operators
| Language Reference 
| Home | Site Map |

 
See Also
Description
Used to compare expressions.

Syntax

result = expression1 comparisonoperator expression2

result = object1 Is object2

result = string Like pattern

Comparison operators have these parts:

PartDescription
resultAny numeric variable.
expressionAny expression
.

comparisonoperatorAny comparison operator
.

objectAny object name.
stringAny string expressionComparison Operators.
patternAny string expression or range of characters.

Remarks

The Is operator has specific comparison functionality that differs from the operators in the following table. The following table contains a list of the comparison operators and the conditions that determine whether result is True, False, or Null:

OperatorDescriptionTrue ifFalse ifNull if
<Less thanexpression1 < expression2expression1 >= expression2expression1 or expression2 = Null
<=Less than or equal toexpression1 <= expression2expression1 > expression2expression1 or expression2 = Null
>Greater thanexpression1 > expression2expression1 <= expression2expression1 or expression2 = Null
>=Greater than or equal toexpression1 >= expression2expression1 < expression2expression1 or expression2 = Null
=Equal toexpression1 = expression2expression1 <> expression2expression1 or expression2 = Null
<>Not equal toexpression1 <> expression2expression1 = expression2expression1 or expression2 = Null

When comparing two expressions, you may not be able to easily determine whether the expressions are being compared as numbers or as strings.

The following table shows how expressions are compared or what results from the comparison, depending on the underlying subtype:

If Then
Both expressions are numericPerform a numeric comparison.
Both expressions are stringsPerform a string comparison.
One expression is numeric and the other is a stringThe numeric expression is less than the string expression.
One expression is Empty and the other is numericPerform a numeric comparison, using 0 as the Empty expression.
One expression is Empty and the other is a stringPerform a string comparison, using a zero-length string as the Empty expression.
Both expressions are EmptyThe expressions are equal.


© 1996 by Microsoft Corporation.