Easy Sample VB Scripts - Case

CASE:
Using 'case' to make a decision based on a variable:

'get weekday as a number - Sunday is one through to Saturday which is 7

'declare variable 'daynumber' and pass it the weekday number
daynumber = weekday(date)

Select Case daynumber
   Case 1
     msgbox("It's Sunday ")
   Case 2
     msgbox("It's Monday ")
   Case 3
     msgbox("It's Tuesday ")
   Case 4
     msgbox("It's Wednesday ")
   Case 5
     msgbox("It's Thursday ")
   Case 6
     msgbox("It's Friday ")
   Case 7
     msgbox("It's Saturday ")
 End Select

Popular Posts