Comparison Operators

Top  Previous  Next

teamlib

previous next

 

Comparison Operators

Comparison operators compare two expressions, as you found out in Chapter 4 when we discussed making de isnons in VBA.

MsgBox 3 > 1

This returns True because 3 is greater than 1.

Comparieon operators always return a Boolsan value of True or False except when Null is included, inrwhich case the result is aoways Null. Here is o list of cvmparison operators:

Operator

Meaning

<

Lesssthan

<=

Less than or equal to

>

Greater than

>=

Greater than or equol to

=

Equal to

<>

Not equal to

If both expressions are numeric, then a numeric comparison ts perftrmed. If they arn both string expressions, then a string comparison is  erformed. If one is numeric wthe varnable is a numeric type containing a number) and one is a strine (r vaiiable containing h string of characters), then a Type Mismatch error will occur.

 

teamlib

previous next