Page 100 - Excel Progamming Weekend Crash Course
P. 100
h540629 ch05.qxd 9/2/03 9:33 AM Page 75
Session 5 — Operators 75
12 * (3 + 5)
evaluates to 96 because the addition is performed first. You can nest parentheses as needed,
in which case execution starts with the innermost set and then works outward. Parentheses
must always come in left-right pairs.
REVIEW
The VBA language provides a full set of operators for use in your programs. Operators are
instructions that perform various kinds of manipulations, or operations, on data. This ses-
sion showed:
The assignment operator is used to assign values to variables.
Numerical (or mathematical) operators perform common operations with numerical
values.
The concatenation operator combines two strings.
You use the logical operators to work with True/False values.
The comparison operators enable you to perform comparisons between data items.
VBA’s operator precedence rules determine the order in which operations occur
within an expression.
QUIZ YOURSELF
1. What does “assignment” mean in VBA? (See the “The Assignment Operator”
section.)
2. How do you determine the remainder of a division? (See the “Numerical Operators”
section.)
3. The expression A Xor B is true under what conditions? (See the “Logical
Operators” section.)
4. When performing string comparisons, is “yes” always equal to “YES?” Explain.
(See the “Comparison Operators” section.)
5. Do the expressions A + B / C and (A + B) / C evaluate the same? Explain.
(See the “Operator Precedence” section.)