Clock Counter

R

RobUCSD

I need to have a clock on my form that counts down form 15min to 0. In other
words, I need to set the clock at 15 minutes (or other increment of time,
i.e. 10 min) and have it count down to 0 and then beep or make some other
noise when it reaches 0.

Anyone have any ideas on how to do this?

Thanks, Robert
 
D

Damian S

Hi Rob,

Use an On Timer event and set your timer interval to 1000 (1 second). You
could then have a textbox that displays the elapsed time (or display it as a
number of minutes minus the elapsed number of seconds) that is updated in the
on timer event.

Have your on timer check that the elapsed time is less than the number of
mins you are counting and when it's finished, use BEEP to make it beep and
set the timer interval to 0 to stop the timer.

Hope this helps.

Damian.
 
R

RobUCSD

I'm not sure how to execute your suggestion. Rob

Damian S said:
Hi Rob,

Use an On Timer event and set your timer interval to 1000 (1 second). You
could then have a textbox that displays the elapsed time (or display it as a
number of minutes minus the elapsed number of seconds) that is updated in the
on timer event.

Have your on timer check that the elapsed time is less than the number of
mins you are counting and when it's finished, use BEEP to make it beep and
set the timer interval to 0 to stop the timer.

Hope this helps.

Damian.
 
D

Damian S

Hi Rob,

Here's the code you need:

Option Compare Database
Option Explicit

Dim lngSeconds As Integer
Const NUMSECONDS = 600

Private Sub Form_Open(Cancel As Integer)
lngSeconds = 0
End Sub

Private Sub Form_Timer()

Me.txtCountdown = ((NUMSECONDS - lngSeconds) \ 60) & ":" & Format((600 -
lngSeconds) Mod 60, "00")
lngSeconds = lngSeconds + 1

If lngSeconds >= NUMSECONDS Then
Beep
MsgBox "Time's up"
' turn off timer
Me.TimerInterval = 0
End If
End Sub

You might need to tweak it to get the format how you like it, but the guts
of it is there. Enjoy!!

Damian.
 
R

RobUCSD

Thanks Damian, I'll try this tomorrow and let you know via this thread how it
turned out. I appreciate your help.

Rob
 
N

Naeem Azizian

I'm not sure how to execute your suggestion. Rob

On the main form properties and in the Event Tab. there are two lines.
one says: Timer Interval, type 1000 as Damian says. and then On Timer
event type something like:

Private Sub Form_Timer()
'i am thinking as if you reduce the time by a second at a time
timerfirstvalue = #timerfirstvalue# - #00:00:01#

if timerfirstvalue <= 0 then
'do what you want
end if

End sub
 
Top