Grouping Constants with Enumerations

Enumerations are another kind of value type available in the .NET Framework. They represent a group of constants enclosed within an Enum..End Enum code block. An enumeration derives from System.Enum, which derives from System.ValueType. The following is an example of enumeration:

'These are all IntegersPublic Enum Sports    Biking      '0    Climbing    '1    Swimming    '2    Running     '3    Skiing      '4End Enum

By default, enumerations are sets of integer values. The preceding code defines a Sports enumeration of type Integer, which stores a set of integer constants. The Visual Basic compiler can also automatically assign an integer value to each member within an enumeration, starting from zero, as ...

Get Visual Basic 2015 Unleashed 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.