Using Enumerations
You use enumerations as any other .NET type. For example, consider the following method that receives the Sports
enumeration as an argument and returns a response depending on what value has been passed:
The following code snippet then declares a variable of type Sports
, assigns a value, and then invoke the method passing the variable:
Dim mySport As Sports = Sports.Climbing AnalyzeSports(mySport)
Notice how IntelliSense comes in when you need to specify a value whose type is an enumeration. Figure 11.1 shows the IntelliSense’s pop-up window related to our custom enumeration.
Get Visual Basic® 2010 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.