Results 1 to 3 of 3

Thread: Switch in VB?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2003
    Location
    Mt. Holly, NJ
    Posts
    31

    Switch in VB?

    Hi all,

    Wanted to knof if there is something in VB (using Office 97) comprable to a switch command like in C++ such as

    Switch (Variable) {

    2: X = 5
    3: x = 10

    }

    Otherwise, it's just a lot of if then statements that will make my code rather large and clunky.

    Thanks,
    Joshua Wise

  2. #2
    Member
    Join Date
    Feb 2003
    Posts
    40
    Hello,

    Yes there is something like the switch statement in c++.
    It is the select case statement.

    Try the example and change the value of intChoice

    --------------------------------------------------------
    Dim intChoice As Integer

    intChoice = 2

    Select Case intChoice
    Case 0
    MsgBox "intChoice is 0"
    Case 1
    MsgBox "intChoice is 1"
    Case Else
    MsgBox "intChoice is in the else section."
    End Select

    End Sub
    -----------------------------------------------------------

    Greets,
    J@B@R

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Mar 2003
    Location
    Mt. Holly, NJ
    Posts
    31
    Thanks very much, I've never seen that before...guess that's the downfall of being an autodidact.

    Peace,
    Joshua Wise

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width