timothy1
asked on
Using System Time
I created a clock application identical to the one in the MSDN help system example.
I also created a public variant variable called AlarmTime in the subroutine for the timer as seen below I have it check to see if the AlarmTime is less then Time or if it is not equal to 0. "0" is what the variable is set to if no alarm time is entered into a masked edit box on the form.
Play_Sound is a sub that calls a WIN32.API function for the alarm sound.
The whole thing works perfect as long as the AlarmTime variable is not above 09:59:59 AM, after that it plays as soon as you set the alarm, it would seem that it thinks 10:00:00 AM is < then 9:00:00 AM. I thought the system time was the number of seconds since midnight. How do I fix the sub below?
Private Sub Timer1_Timer()
If lblTime.Caption <> CStr(Time) Then
lblTime.Caption = Time
If AlarmTime < CStr(Time) And AlarmTime <> 0 Then
Play_Sound
End If
End If
End Sub
I also created a public variant variable called AlarmTime in the subroutine for the timer as seen below I have it check to see if the AlarmTime is less then Time or if it is not equal to 0. "0" is what the variable is set to if no alarm time is entered into a masked edit box on the form.
Play_Sound is a sub that calls a WIN32.API function for the alarm sound.
The whole thing works perfect as long as the AlarmTime variable is not above 09:59:59 AM, after that it plays as soon as you set the alarm, it would seem that it thinks 10:00:00 AM is < then 9:00:00 AM. I thought the system time was the number of seconds since midnight. How do I fix the sub below?
Private Sub Timer1_Timer()
If lblTime.Caption <> CStr(Time) Then
lblTime.Caption = Time
If AlarmTime < CStr(Time) And AlarmTime <> 0 Then
Play_Sound
End If
End If
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Actually, in the example I gave, I didn't convert the "alarm time" into a date using CDate, I just concatenated a string of date in the format of mm/dd/yyyy with a space and then with a string of time in the format of hh:nn:ss AM/PM.
ASKER
Thanks