Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Timer or clock problem

Status
Not open for further replies.

medic133

Technical User
Apr 7, 2002
86
US
I have developed a db for my kids that is made up of simple math problems. I would like to display a timer or clock (I don't know which), perhaps in a textbox that shows the time interval between two events (the time elapsed to answer ... say 10 math problems). How can I accomplish this?
 
hi,

Here's a way. The procedure puts the count down seconds in A1 -- be sure to format A1 GENERAL and NOT TIME...
Code:
Sub CountDownTimer()
    Dim PauseTime, Start, Finish, TotalTime, x
    PauseTime = 10  ' Set duration in seconde
    Start = Timer    ' Set start time.
    y = Int(Start + PauseTime)
    Do While Timer < Start + PauseTime
        DoEvents    ' Yield to other processes.
        t = Int(Timer)
        x = y - t
        [A1].Value = x
    Loop
End Sub


Skip,
Skip@TheOfficeExperts.com
 
Here's another approach:

Dim StartTime As Date, CancelTimer As Boolean

Sub TimeIt()
[a1] = Now - StartTime
If Not CancelTimer Then Application.OnTime Now + 1 / 3600 / 24, &quot;timeit&quot;
End Sub

Sub StartTimer()
StartTime = Now
Application.OnTime Now + 1 / 3600 / 24, &quot;timeit&quot;
End Sub

Sub StopTimer()
CancelTimer=true
end sub

Between calls to StartTimer and StopTimer, the cell in A1 (in this case formatted as hh:mm:ss) shows the elapsed time, updating once a second.





Rob
[flowerface]
 
Oops. Forgot one assignment:

Sub StartTimer()
StartTime = Now
CancelTimer=false
Application.OnTime Now + 1 / 3600 / 24, &quot;timeit&quot;
End Sub


Rob
[flowerface]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top