| Part | Description | |
| result | Required; any numeric variable. | |
| expression | Required; any expression. | |
| comparisonoperator | Required; any comparison operator. | |
| Part | Description | |
| object | Required; any object name. | |
| string | Required; any string expression. | |
| pattern | Required; any string expression or range of characters. | |
| Operator | True if | False if | Null if | |
| < (Less than) | expression1 < expression2 | expression1 >= expression2 | expression1 or expression2 = Null | |
| <= (Less than or equal to) | expression1 <= expression2 | expression1 > expression2 | expression1 or expression2 = Null | |
| > (Greater than) | expression1 > expression2 | expression1 <= expression2 | expression1 or expression2 = Null | |
| >= (Greater than or equal to) | expression1 >= expression2 | expression1 < expression2 | expression1 or expression2 = Null | |
| = (Equal to) | expression1 = expression2 | expression1 <> expression2 | expression1 or expression2 = Null | |
| <> (Not equal to) | expression1 <> expression2 | expression1 = expression2 | expression1 or expression2 = Null | |
| If | Then | |
| Both expressions are numeric data types (Byte, Boolean, Integer, Long, Single, Double, Date, Currency, or Decimal) | Perform a numeric comparison. | |
|---|---|---|
| Both expressions are String | Perform a string comparison. | |
| One expression is a numeric data type and the other is a Variant that is, or can be, a number | Perform a numeric comparison. | |
| One expression is a numeric data type and the other is a string Variant that can't be converted to a number | A Type Mismatch error occurs. | |
| One expression is a String and the other is any Variant except a Null | Perform a string comparison. | |
| One expression is Empty and the other is a numeric data type | Perform a numeric comparison, using 0 as the Empty expression. |
| One expression is Empty and the other is a String | Perform a string comparison, using a zero-length string (" ") as the Empty expression. |
| If | Then | |
| Both Variant expressions are numeric | Perform a numeric comparison. | |
| Both Variant expressions are strings | Perform a string comparison. | |
| One Variant expression is numeric and the other is a string | The numeric expression is less than the string expression. | |
| One Variant expression is Empty and the other is numeric | Perform a numeric comparison, using 0 as the Empty expression. | |
| One Variant expression is Empty and the other is a string | Perform a string comparison, using a zero-length string ("") as the Empty expression. | |
| Both Variant expressions are Empty | The expressions are equal. | |
Dim MyResult, Var1, Var2
MyResult = (45 < 35) ' Returns False.
MyResult = (45 = 45) ' Returns True.
MyResult = (4 <> 3) ' Returns True.
MyResult = ("5" > "4") ' Returns True.
Var1 = "5": Var2 = 4 ' Initialize variables.
MyResult = (Var1 > Var2) ' Returns True.
Var1 = 5: Var2 = Empty
MyResult = (Var1 > Var2) ' Returns True.
Var1 = 0: Var2 = Empty
MyResult = (Var1 = Var2) ' Returns True.