The following table contains a list of the comparison operators and the conditions that determine whether result is True or False.
Operator | True if | False if |
---|---|---|
< (Less than) | expression1 < expression2 | expression1 >= expression2 |
<= (Less than or equal to) | expression1 <= expression2 | expression1 > expression2 |
> (Greater than) | expression1 > expression2 | expression1 <= expression2 |
>= (Greater than or equal to) | expression1 >= expression2 | expression1 < expression2 |
= (Equal to) | expression1 = expression2 | expression1 <> expression2 |
<> (Not equal to) | expression1 <> expression2 | expression1 = expression2 |
Note The Is and Like operators have specific comparison functionality that differs from the operators in the table.
If expression1 and expression2 are both Object expressions, their underlying type determines how they are compared. The following table shows how the expressions are compared or the result from the comparison, depending on the underlying type of the Object:
Question: Will we need a table of some kind?
When a Single is compared to a Double, the Single is converted to a Double.
Similarly, when a Decimal is compared with a Single or Double, the Decimal will be converted to a Single or Double. For Decimal, any fractional value less than 1E-28 may be lost, or an overflow error can occur. Such fractional value loss may cause two values to compare as equal when they are not.
= Operator | Is Operator | Like Operator | Operator Precedence in Visual Basic | Operator Summary | Option Compare Statement