What is a real efficient way of doing making an alarm, i need the current time shown in a label, the alarm time in another and the countdown in another. I am setting and getting the alarm time alright. But this countdown part and then the actual alarm is a little tricky.
As for format, doesn't matter at the moment, but the current time is just...
Code:
lblTime = Time
then the format for the alarm time at the moment is "hh:mmAM" So the input would be "8:45AM or 845:PM" now i just sort of need the countdown time. Any ideas?
Private daAlarmTime As Date
Private daCountDown As Date
Private daNow As Date
Private Sub cmdStartCountDown_Click()
Timer1.Enabled = True
daAlarmTime.Caption = CDate(labAlarmTime.Caption)
End Sub
Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 1000
labCurrentTime.Caption = Format(Now, "hh:mm:ss")
daAlarmTime = CDate(InputBox("Enter Alarm Time"))
labAlarmTime.Caption = Format(daAlarmTime, "hh:mm:ss")
End Sub
Private Sub Timer1_Timer()
Dim daDiff As Date
labCurrentTime.Caption = Format(Now, "hh:mm:ss")
daNow = CDate(labCurrentTime.Caption)
daDiff = daAlarmTime - daNow
labTimeToGo.Caption = Format(daDiff, "hh:mm:ss")
If daNow >= daAlarmTime Then
MsgBox "ALARM"
Timer1.Enabled = False
End If
End Sub
Last edited by Doogle; Feb 9th, 2008 at 05:10 AM.
Reason: Missed a couple of .Caption's
HI, Wish i had a bit more time to right this but just kind of chucked it together, if you ahve a timer on your form, set the timer to 1000 interval and use something like this
vb Code:
'//Top of the Code Section
Private AlarmTime As Date
Private Sub Form_Load()
lblTime = Time
'//Set Alarm TIme To 8pm but in 24 hour
'//When you update your Alarm Time Label, you can
'//Change the format of the time to display how you want
AlarmTIme = "20:00"
End Sub
Private Sub Timer1_Timer()
'//Update The Label
lblTime = Time
'//Works it out in 24 hour format then you dont need to check _
'//To see if it is AM or PM
If Format(Time, "hh:mm") = Format(AlarmTime, "hh:mm") Then
'//Alarm Code Here
MsgBox "alarm"
'//Stop The Timer to stop duplicate alarms running
Here is what i wrote, so i could show you the code
thought it might jus be as easy to upload the example
so that you can see, ive added a little checks here and there aswell
Well, it displayed the current time (labCurrentTime), the alarm time (labAlarmTime) and displayed a count down, second by second (labTimeToGo). I obviously didn't understand you question. Sorry.