Author | Message |
---|
Corayzon Regular Posts: 67
| The case statment is a good alternative to large if statements that have upto 10 elseif's
Code: | Private Sub Form_Load() Dim iCount As Integer For iCount = 1 To 10 Select Case iCount Case 1 MsgBox "1" Case Is = 2 MsgBox "2" Case Is <= 3 MsgBox "3" Case Is >= 4 MsgBox 4 End Select Next iCount End Sub |
|
Exile n00b Posts: 30
| Correction: Case Is >= 4 MsgBox "4" not Case Is >= 4 MsgBox 4 Exile
|
Meka][Meka Unstopable Posts: 700
|
Quoted from Corayzon | The case statment is a good alternative to large if statements that have upto 10 elseif's
Code: | Private Sub Form_Load() Dim iCount As Integer For iCount = 1 To 10 Select Case iCount Case 1 MsgBox "1" Case Is = 2 MsgBox "2" Case Is <= 3 MsgBox "3" Case Is >= 4 MsgBox 4 End Select Next iCount End Sub | | dont forget to mension case else 8)
Code: | Private Sub Form_Load() Dim iCount As Integer For iCount = 1 To 10 Select Case iCount Case 1 MsgBox "1" Case Is = 2 MsgBox "2" Case Is <= 3 MsgBox "3" Case else: MsgBox "4" End Select Next iCount End Sub |
|