Comparison Operators


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

 MsgBox 3 > 1 

This returns True because 3 is greater than 1.

Comparison operators always return a Boolean value of True or False except when Null is included, in which case the result is always Null. Here is a list of comparison operators:

Operator

Meaning

<

Less than

<=

Less than or equal to

>

Greater than

>=

Greater than or equal to

=

Equal to

<>

Not equal to

If both expressions are numeric, then a numeric comparison is performed. If they are both string expressions, then a string comparison is performed. If one is numeric (the variable is a numeric type containing a number) and one is a string (a variable containing a string of characters ), then a Type Mismatch error will occur.




Excel VBA Macro Programming
Excel VBA Macro Programming
ISBN: 0072231440
EAN: 2147483647
Year: 2004
Pages: 141

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net