O'Reilly logo

VB.NET Language in a Nutshell, Second Edition by Steven Roman PhD, Paul Lomax, Ron Petrusha

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

Enum Statement

Syntax

                  accessmodifier Enum name [As type]
                  membername [= constantexpression]
   membername [= constantexpression]
   ...
End Enum
accessmodifier (optional; Keyword)

The possible values of accessmodifier are Public, Private, Friend, Protected, or Protected 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, and Long.

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, or Protected 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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required