Dela via


How to: Refer to an Enumeration Member (Visual Basic)

Enumerations provide a convenient way to work with sets of related constants and to associate constant values with names. For example, you can declare an enumeration for a set of integer constants associated with the days of the week, and then use the names of the days rather than their integer values in your code.

You can avoid using fully qualified names with the Imports statement. For more information, see Enumerations and Name Qualification (Visual Basic).

To refer to an enumeration member

  • Qualify the member name with the enumeration. For example, the following example assigns the Saturday member of the FirstDayOfWeek enumeration to the variable DayValue.

    DayValue = FirstDayOfWeek.Saturday
    

See Also

Tasks

How to: Declare Enumerations (Visual Basic)

How to: Iterate Through An Enumeration in Visual Basic

How to: Determine the String Associated with an Enumeration Value (Visual Basic)

Concepts

Enumerations and Name Qualification (Visual Basic)

When to Use an Enumeration (Visual Basic)