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 which value has been passed:
Private Sub AnalyzeSports(ByVal sportsList As Sports) Select Case sportsList Case Is = Sports.Biking Console.WriteLine("So, do you really like biking my friend?") Case Is = Sports.Climbing Console.WriteLine("I do not like climbing like you!") Case Else Console.WriteLine("Every sport is good!") End SelectEnd Sub
The following code snippet then declares a variable of type Sports
, assigns a value, and then invokes the method by passing the ...
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.