Using a timer

T

Tha BeatMaker

I need to create a timer that counts off seconds on my form. For
example, I need to click on button 1 and testbox 1 starts counting off
1, 2, 3, etc.... and the timer stops when i click button 2, leaving the
final time count in testbox 1.

How can I do this?
 
K

KCarhart

Hi Beatmaker,

I don't know if you need help with the triggering itself, but take a
look at this timer code. This example puts the timer in the status bar
rather than on a form. If you want to be able to do something else
while it runs, you can uncomment the DoEvents.

Sub timer_example()


timeout_limit = 10
start_time = Time()

Do While time_difference < timeout_limit
Application.StatusBar = time_difference & " seconds elapsed out
of " & timeout_limit
'DoEvents
current_time = Time()
time_difference = DateDiff("s", start_time, current_time)
Loop

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top