## Operators

Operators are elements of a programming language you can use to either make comparisons or change the value of program elements in some way. One of the primary uses of elements is to perform mathematical operations. For mathematical operations, using these operators is similar to how you'd use them to express any basic equation. Therefore, I won't spend a lot of time covering operators as they apply to mathematical operations. Table 3.3 lists all of the operators available to you.

Table 3.3: vba Operators

Operator

description

Used to join two or more strings together to form a single string. Used to perform multiplication.

Table 3.3: vba Operators (continued)

Operator description

+ Addition operator.

Subtraction operator.

/ Floating-point division operator.

\ Integer division operator.

A Used to raise a number to the power of an exponent.

= Assignment operator. Used to assign a value to a variable or property.

AddressOf Used to pass the address of a procedure to API procedures requiring function pointer.

And Checks two expressions to see if both expressions are true.

Comparison Operators The various combinations of =, <, and > used to compare expressions.

Eqv Performs a logical equivalence on two expressions.

Imp Performs a logical implication on two expressions.

Is Used to compare object references.

Like Used to compare strings.

Mod Used to find the remainder resulting from the division of two numbers.

Not Performs logical negation.

Or Checks two expressions to see if one or both are true.

Xor Checks two expressions to see if one and only one expression is true.

Other than the mathematical operators, you'll usually find yourself using the comparison operators alone or in conjunction with And, Is, Not, and Or to implement logic in order to determine when to terminate loops, or as part of an If.. .Then statement. Looping and If.. .Then statements are covered in the next section.

## Post a comment