Name
Enum Statement
Syntax
accessmodifier
Enumname [As type]
membername
[=constantexpression
]membername
[=constantexpression
] ... End Enum
-
accessmodifier
(optional; Keyword) The possible values of
accessmodifier
arePublic
,Private
,Friend
,Protected
, orProtected
Friend
. For more information, see Section 4.7 in Chapter 4.-
name
(required; String literal) The name of the enumerated data type.
-
membername
(required; String literal) The name of a member of the enumerated data type.
-
constantexpression
(optional; Long) The value to be assigned to
membername
.-
type
(optional; Keyword) The data type of the enumeration. All enumerated members must be integers; possible values are
Byte
,Short
,Integer
, andLong
.
Description
Defines an enumerated data type. All of the values of the data type
are defined by the instances of
membername
.
Rules at a Glance
The
Enum
statement can only appear at module level, in the declarations section of a form, code module, or class module.Access rules for Enums are the same as for variables and constants. In particular, the optional
accessmodifier
can be any one of the following:Public
,Private
,Protected
,Friend
, orProtected
Friend
. The following table describes the effects of the various access modifiers:
Direct access scope |
Class/object access scope | |
---|---|---|
Private |
Declaring class |
Declaring class |
Protected |
All derived classes |
Declaring class |
Friend |
Derived in-project classes |
Declaring project |
Protected Friend |
All derived classes |
Declaring project |
Get VB.NET Language in a Nutshell, Second Edition 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.