Enumerated Types

An enumerated type is a type of data that allows each member of a class of objects to be described in English. Enumerated types are available in C++ and Visual Basic and are generally used when you know all the possible values of a variable and want to express them in words. Here are some examples of enumerated types in Visual Basic:

Example 12-13. Visual Basic Examples of Enumerated Types

Public Enum Color
   Color_Red
   Color_Green
   Color_Blue
End Enum

Public Enum Country
   Country_China
   Country_England
   Country_France
   Country_Germany
   Country_India
   Country_Japan
   Country_Usa
End Enum

Public Enum Output
   Output_Screen
   Output_Printer
   Output_File
End Enum

Enumerated types are a powerful alternative to shopworn schemes in which you explicitly ...

Get Code Complete, 2nd 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.