|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
v |
Expressions
are formulae made from variables and operators,
|
|
|
e.g.
calculator operations: +, -, *, /, ^
|
|
|
|
o |
weeks = days / 7 divide value of days by
7
|
|
|
|
o |
grossPay = hours * rate multiply the two values
|
|
|
|
o |
area = pi * radius ^ 2 p times radius squared
|
|
|
v |
In
the last example, the ^ operator has precedence over the *
|
|
|
operator.
|
|
|
v |
We
could also write
|
|
|
|
o |
area = pi * (radius ^ 2)
|
|
|
v |
When
in doubt, use extra parentheses in expressions! It’s
|
|
|
always
safe.
|
|
|
v |
See
the Snyder text for more about precedence, and page 77 of
|
|
the
VB book for a complete table of operator precedence in VB.
|
|