The comparison operators compare two items of the same general type to produce a logical value of TRUE or FALSE. Although you cannot directly compare numeric data with non-numeric data (e.g., string expressions), a comparison expression can compare integer, SmallInt, and float data types. Comparison operators are often used in conditional expressions, such as If...Then.
Operator | Returns TRUE if: | Example |
---|---|---|
= |
a is equal to b |
|
<> |
a is not equal to b |
|
< |
a is less than b |
|
> |
a is greater than b |
|
<= |
a is less than or equal to b |
|
>= |
a is greater than or equal to b |
|
The Between...And... comparison operator lets you test whether a data value is within a range. This operator is inclusive (for example, X >= 500 And X <= 600). It works with string and date types as well as with numeric values, and it can be used in a WHERE clause in a SQL query. The following If...Then statement uses a Between...And... comparison:
If x Between 0 And 100 Then
Note "Data within range."
Else
Note "Data out of range."
End If