Microsoft Office Tutorials and References
In Depth Information
Chocolate
Strawberry
Banana
End Enum
This creates an enumeration called Flavors with the constants Vanilla equal to 0, Chocolate
equal to 1, and so on. If you do not want the enumeration values assigned sequentially starting at 0,
you can specify the values:
Enum Flavors
Vanilla = 2
Chocolate = 3
Strawberry = 5
Banana = 10
End Enum
Enumerations can be defined only at the module level. Once an Enum is defined, it becomes
available as a data type you can use to declare variables:
Dim IceCreamCone As Flavors
A variable declared as an enumerated type can only take on the set of values defined in the
enumeration. A real convenience is that VBA displays autolist members for enumerated types, permitting
you to select from a list of the enumeration’s constants.
Using Operators
Operators are symbols that instruct VBA to manipulate data in some manner, for example
multiplying two numbers. The operators available in VBA fall into several categories.
The Assignment Operator
The assignment operator (=) tells VBA to assign a value to a variable. Specifically, the value of the
expression on the right side of the operator is assigned to the variable on the left side of the
operator. For example, the statement
x = 15
assigns the value 15 to x .
The Mathematical Operators
The mathematical operators perform the common operations such as addition and division. There
are the four common arithmetic operations as follows:
Search JabSto ::




Custom Search