在从用户表单设置约会之前,如何在Excel中检查输入的日期和时间是否正常?理想情况下,如果时间不可用,我希望显示“msgbox” . 这是我当前的代码,它从我的userform设置从excel到outlook的约会:

Sub outlook_call()


Dim cb As Object
Dim lastrow As Long, ws As Worksheet
Set ws = Sheets("appointments")
lastrow = ws.Cells(Rows.Count, 11).End(xlUp).Row + 1

'Outlook begin here////////////
' Create the Outlook session
    Set myOutlook = CreateObject("Outlook.Application")


    Do Until appvision.appname.Value = ""
        ' Create the AppointmentItem
        Set myApt = myOutlook.CreateItem(1)
        ' Set the appointment properties
        myApt.Subject = appvision.appname.Value
        myApt.Location = appvision.appname.Value
        myApt.Start = appvision.TextBox2.Value
        'myApt.Duration = appvision.ComboBox1.Value
         'If Busy Status is not specified, default to 2 (Busy)
        'If UserForm2.ComboBox3.Value = "" Then
         '  myApt.BusyStatus = 2
        'Else
           ' myApt.BusyStatus = UserForm2.ComboBox3.Value
       ' End If
        If appvision.TextBox9.Value > 0 Then
          myApt.ReminderSet = True
           myApt.ReminderMinutesBeforeStart = appvision.TextBox9.Value
        Else
            myApt.ReminderSet = False
        End If
        myApt.Body = appvision.TextBox4.Value
        myApt.Display
    Exit Do
    Loop
    End Sub