mercredi 25 mai 2016

If statement to case statement visual basics

I want to use case statement instead of if code. Here is my if statement

If A > 10 And A < 20 Then
'do 1
ElseIf A > 21 And A < 30 Then
' do 2
ElseIf A > 31 And A < 40 Then
' do 3
ElseIf A > 41 and A <50 Then
' do 4

End If

And here is my case statement which does not work properly.

Select Case A
    Case 10 To 20:
    do 1
    Case 21 To 30:
    do 2
    Case 31 To 40:
    do 3
    Case 41 To 50:
    do 4

End Select

I would be thankful if you could help me with my case code. it does not print all of the outputs which is my challenge.Thanks,

Aucun commentaire:

Enregistrer un commentaire