Enum Statement |
Named Arguments
No
Syntax
[Public | Private] Enum name membername [= constantexpression] membername [= constantexpression] . . . End Enum
name
Use: Required
The name of the enumerated data type.
membername
Use: Required
The name of a member of the enumerated data type.
constantexpression
Use: Optional
Data Type: Long
The value to be assigned to membername.
Description
Defines an enumerated data type. All the values of the data type are defined by the instances of membername.
Rules at a Glance
The Enum statement can appear only at module level, in the declarations section of a form, code module, or class module.
The Public keyword makes the enumerated data type visible throughout the project in which it's used; this is the default behavior. Note that adding a reference to a library containing public enumerated types to a project makes those types visible to the project. A class doesn't have to be instantiated to access these enumerated types.
The Private keyword makes the enumerated data type visible only to the module in which it appears.
constantexpression must evaluate to a Long. It can be either a negative or a positive number. It can also be another member of an enumerated data type or an expression that includes long integers and enumerated data types.
If you assign a floating point value to constantexpression, it's rounded and converted to a long integer automatically.
If constantexpression is omitted, the value assigned to membername is if it's the first ...
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.