共用方式為


How to: Group Related Constant Values Together 

An enumeration is the best way to group related constants together. You create an enumeration with the Enum statement in the declarations section of a class or a module. For more information, see How to: Declare Enumerations.

  1. Write a declaration that includes a code access level, the Enum keyword, and a valid name. This example creates the Private enumeration, temperatureValues.

    Private Enum temperatureValues
    
  2. Define the constants in the enumeration. This example creates the Public enumeration temperatureValues and assigns its values.

    Public Enum temperatureValues
      Scorching
      Hot
      Lukewarm
      Cool
      Cold
    End Enum
    

See Also

Tasks

How to: Refer to an Enumeration Member

Concepts

Enumerations and Name Qualification
When to Use an Enumeration
Intrinsic Constants and Enumerations
Constants Overview
Constant and Literal Data Types