-
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
-
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
-
Thanks very much, I've never seen that before...guess that's the downfall of being an autodidact.
Peace,
Joshua Wise