Put a button on a form and add this code in the click event:
Private Sub Command1_Click()
Dim x As Date
Dim starttime As Date
Dim endtime As Date
starttime = "5:00:00 AM"
endtime = "8:00:00 AM"
For x = starttime To endtime Step "00:30:00"
Debug.Print x
Next
End Sub
Run the project and click the button. You will see that each half hour from 5 AM to 8 AM is printed, as expected. Now change the AM to PM on the starttime and endtime variables and run it again. This time it only prints up to 7:30 PM. What happened to 8:00? Anyone know what's going on?
Private Sub Command1_Click()
Dim x As Date
Dim starttime As Date
Dim endtime As Date
starttime = "5:00:00 AM"
endtime = "8:00:00 AM"
For x = starttime To endtime Step "00:30:00"
Debug.Print x
Next
End Sub
Run the project and click the button. You will see that each half hour from 5 AM to 8 AM is printed, as expected. Now change the AM to PM on the starttime and endtime variables and run it again. This time it only prints up to 7:30 PM. What happened to 8:00? Anyone know what's going on?