Can't stop a clock

N

NDBC

I have a clock on a userform that shows the time since the race started (now
- start time). The clock works fine but I would like to be able to stop the
clock.

This is the code that runs the clock

In the userform1 section

Private Sub UserForm_Activate()
RClock1
End Sub

And in the module1 section

Sub Main()
Load UserForm1
UserForm1.Show
End Sub

Sub RClock1()
Start = Sheets("Timing Sheet").Range("B6")
Watch = Now - Start
UserForm1.RaceClock1.Text = Format(Watch, "hh:mm:ss")
NextTick = Now + TimeValue("00:00:01")
Application.OnTime NextTick, "RClock1"
End Sub


I tried to write code to stop the clock from a command button (Exit1). This
is it.

In userform1 section

Private Sub Exit1_Click()
Call StopC
End Sub

In the module1 section

Sub StopC()
On Error Resume Next
Application.OnTime NextTick, "RClock1", , False
End Sub


Does not work. I'm assuming the fact that the clock function is working with
spreadsheets is causing me hassles. Anybody got a better way. Thanks.
 
D

Dave Peterson

Check your other post.
I have a clock on a userform that shows the time since the race started (now
- start time). The clock works fine but I would like to be able to stop the
clock.

This is the code that runs the clock

In the userform1 section

Private Sub UserForm_Activate()
RClock1
End Sub

And in the module1 section

Sub Main()
Load UserForm1
UserForm1.Show
End Sub

Sub RClock1()
Start = Sheets("Timing Sheet").Range("B6")
Watch = Now - Start
UserForm1.RaceClock1.Text = Format(Watch, "hh:mm:ss")
NextTick = Now + TimeValue("00:00:01")
Application.OnTime NextTick, "RClock1"
End Sub

I tried to write code to stop the clock from a command button (Exit1). This
is it.

In userform1 section

Private Sub Exit1_Click()
Call StopC
End Sub

In the module1 section

Sub StopC()
On Error Resume Next
Application.OnTime NextTick, "RClock1", , False
End Sub

Does not work. I'm assuming the fact that the clock function is working with
spreadsheets is causing me hassles. Anybody got a better way. Thanks.
 

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

Similar Threads

Can't Stop the clock 2
Elapsed times > 24hrs 12
Stop timer. 7
How do i stop a clock in excel 0
clock on user form 6
Stop the clock 1
countdown clock 0
Count Timer Pause and Stop button 0

Top