Working with Enumerated Types

Enumerated types can be used when you want to require a property value to be limited to a specified list of constants. Suppose you have the following code in the General Declarations section of a clsCar object:

Public Enum SpecialFeaturesList SunRoof MoonRoof

NavigationSystem IntegratedPhone Other End Enum

In the property declarations, you see the SpecialFeaturesList enumerated type in the list of objects available, as shown in Figure 4.13.

The Property Get and Property Let procedures using the SpecialFeaturesList enumeration look like this:

Public Property Get SpecialFeatures() As SpecialFeaturesList

SpecialFeatures = SpecialFeaturesVal End Property

Public Property Let SpecialFeatures(ByVal Value As SpecialFeaturesList)

SpecialFeaturesVal = Value End Property

Fiibiic Froperty Set SpeciaiFeatures (} A3

SpeciaiFeatures - SpeciaiFeanure: 0 SmartTagActions

End Property_gg SmartTagProperties iS SmarfTagPropert,' Froperty Let SpeciaiFeatures {Bj^gj Smar1Tags


SpecialFeanuresVai End Property


Figure 4.13

# ¬°Sjpeci alF satures List JA StdFont H\ stdole

Now any time you try to set that property using an assignment statement, you are limited to those values specified in the enumeration declaration, as shown in Figure 4.14.

Figure 4.14
0 0

Post a comment