Enum Definition

Syntax

[ | Private | Public ] _
Enum name [ As type ]
    elem [ = value]
   [...]
End Enum

Group

Declaration

Description

Define a new user enum. The optional type overrides the default Long element type. You can specify Byte, Integer, Long, SByte, Short, UInteger, ULong, or UShort.

Each elem defines an element of the enum. If value is given then that is the element's value. The value can be any constant integer expression. If value is omitted then the element's value is one more than the previous element's value. If there is no previous element then zero is used.

Access

If no access is specified then Public is assumed.


Enum Days
    Monday
    Tuesday
    Wednesday
    Thursday
    Friday
    Saturday
    Sunday
End Enum
 
Sub Main
    Dim D As Days
    For D = Monday To Friday
        Debug.Print D ' 0 through 4
    Next D
End Sub