Mega Code Archive

 
Categories / VisualBasic Script / Language Basics
 

Using If Then Else Conditional Statement

Sub WhatTypeOfDay()     Dim response As String     Dim question As String     Dim strMsg1 As String, strMsg2 As String     Dim myDate As Date     question = "Enter any date in the format mm/dd/yyyy:" _             & Chr(13) & " (e.g., 11/22/1999)"     strMsg1 = "weekday"     strMsg2 = "weekend"     response = InputBox(question)     myDate = Weekday(CDate(response))     If myDate >= 2 And myDate <= 6 Then         MsgBox strMsg1     Else         MsgBox strMsg2     End If End Sub