Loading user information from Channel 9

Something went wrong getting user information from Channel 9

Latest Achievement:

Loading user information from MSDN

Something went wrong getting user information from MSDN

Visual Studio Achievements

Latest Achievement:

Loading Visual Studio Achievements

Something went wrong getting the Visual Studio Achievements

Content Obsolete

This content is no longer current. We recommend you try the following url for more up to date content: http://channel9.msdn.com/Series/Visual-Basic-Fundamentals-for-Absolute-Beginners

Enumerations and the switch Decision Statement - 19

18 minutes, 10 seconds


Right click “Save as…”

Classes can contain many different types of information, not just Properties and Methods. We begin demonstrating the use of Enumerations because often in the .NET Framework Class Library, properties can only be set to a pre-determined subset of possible values. To illustrate this point we create our own custom enumeration, and then utilize it in a simple application that demonstrates a third Decision statement, the switch. We demonstrate some Visual Studio IDE magic that will automatically implement code blocks for all possible enumeration values.

Download the source code for Enumerations and the switch...


Follow the discussion

  • Oops, something didn't work.

    Getting subscription
    Subscribe to this conversation
  • Adam SpeightAdam​Speight2008 The Bandito Coder

    A found it a little misleading when you (Bob) refer to the ComplexIfStatement, kind of inferred or suggested that the Select Case decision statement can't do what the ComplexIfStatement does. (Especially with Option Strict Off)

    See Example Below.

    Module Module1
      Sub Main()
      End Sub
      Public Sub SelectCase_Example()
        Console.WriteLine("Select Case Example")
        Dim value = 42
        Select Case value
          Case Is < 1, Is > 100 : Console.WriteLine("Out of bounds")
          Case 23, 42, Is > 90 : Console.WriteLine("You Found one of the special numbers")
          Case Else
            Console.WriteLine("Not one of special numbers")
        End Select
      End Sub
      Public Sub SuperHero_Example()
        Console.WriteLine("SuperHero Example")
      End Sub
      Public Sub GreetSuperHero(ByVal superhero As SuperHeros)
        Dim IsMemberOfSuperHeros = [Enum].IsDefined(GetType(SuperHeros), superhero)
        If IsMemberOfSuperHeros Then
          Console.WriteLine("Hello: {0}", superhero.ToString)
          Console.WriteLine("How Are You?")
        End If
      End Sub
      Enum SuperHeros
      End Enum
    End Module

    When you use Enumerations it can be of any value that the underlying type can be. 

    See Example Code above


  • @AdamSpeight2008:Awesome, awesome comment.  Thank you!  When we re-do this video I'll make sure to revise as you have advised.

Remove this comment

Remove this thread


Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.