Question: Sub ScheduleExams() 'Declare variables Dim examDate As Date Dim examTime As Date Dim examDuration As Integer Dim examLocation As String Dim calendarFolder As String Dim

Sub ScheduleExams()

'Declare variables

Dim examDate As Date

Dim examTime As Date

Dim examDuration As Integer

Dim examLocation As String

Dim calendarFolder As String

Dim emailSubject As String

Dim emailBody As String

Dim emailRecipient As String

'Array to store exam details

Dim exams(1 To 3) As Variant

'Loop through exams

For i = 1 To 3

'Prompt user for exam date and time

exams(i, 1) = InputBox("Enter the exam date (mm/dd/yyyy) for exam #" & i & ":")

exams(i, 2) = InputBox("Enter the exam time (hh:mm AM/PM) for exam #" & i & ":")

'Validate exam date and time

If Not IsDate(exams(i, 1)) Then

MsgBox "Error: Invalid exam date. Please enter a valid exam date (mm/dd/yyyy)."

Exit Sub

End If

If Not TimeValue(exams(i, 2)) Then

MsgBox "Error: Invalid exam time. Please enter a valid exam time (hh:mm AM/PM)."

Exit Sub

End If

'Combine exam date and time into a single Date variable

exams(i, 1) = DateValue(exams(i, 1)) + TimeValue(exams(i, 2))

'Check if exam time is valid (not in the past)

If exams(i, 1) < Now Then

MsgBox "Error: Exam time is in the past. Please enter a valid exam time."

Exit Sub

End If

'Prompt user for exam duration

exams(i, 3) = InputBox("Enter the exam duration (in minutes) for exam #" & i & ":")

'Validate exam duration

If Not IsNumeric(exams(i, 3)) Then

MsgBox "Error: Invalid exam duration. Please enter a valid exam duration (in minutes)."

Exit Sub

End If

'Prompt user for exam location

exams(i, 4) = InputBox("Enter the exam location for exam #" & i & ":")

Next i

'Prompt user for calendar folder

Find the error in the Excel code

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!