C) Select case:-
To alternative code dependences on data instead of conditions , we use this concept.
EX:-1
Option explicit
Dim cctype
Cctype=inputbox(“enter the card type”)
Select case cctype
Case “visa”
Msgbox(“valid card”)
Case “master”
Msgbox(“valid card”)
Case else
Msgbox(“invalid card”)
End select
EX:-2
Option explicit
Dim daynum
Daynum=inputbox(“enter the day number”)
Select case dnum
Case 1
Msgbox(“Sunday”)
Case 2
Msgbox(“Monday”)
Case 3
Msgbox(“Tuesday”)
Case 4
Msgbox(“Wednesday”)
Case 5
Msgbox(“Thursday”)
Case 6
Msgbox(“Friday”)
Case 7
Msgbox(“Saturday”)
Case else
Msgbox(“invalid number”)
End select
No comments:
Post a Comment