C.1. Arithmetic Operators

+

The addition operator. Used to add numeric expressions, as well as to concatenate (join together) two string variables. However, it's preferable to use the concatenation operator with strings to eliminate ambiguity.

Example: result = expression1 + expression2

-

The subtraction operator. Used to find the difference between two numeric values or expressions, as well as to denote a negative value. Unlike the addition operator, it can't be used with string variables.

Example: result = expression1 - expression2

/

The division operator. Returns a floating-point number.

Example: result = expression1 / expression2

*

The multiplication operator. Used to multiply two numerical values.

Example: result = expression1 * expression2

\

The integer division operator. Performs division on two numeric expressions and returns an integer result (no remainder or decimal places).

Example: result = expression1 \ expression2

Mod

The modulo operator. Performs division on two numeric expressions and returns only the remainder. If either of the two numbers is a floating-point number, it's rounded to an integer value prior to the modulo operation.

Example: result = expression1 Mod expression2

^

The exponentiation operator. Raises a number to the power of the exponent.

Example: result = number ^ exponent

Get VB & VBA in a Nutshell: The Language now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.