#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 204
Default Can't Stop the clock

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.
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default Can't Stop the clock

I don't see where you declared NextTick.

This goes at the top of your Module1 (not within any subroutine/function):

Public NextTick as Date



NDBC wrote:

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.


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 204
Default Can't Stop the clock

Thank you heaps. I thought I must have been close.


"Dave Peterson" wrote:

I don't see where you declared NextTick.

This goes at the top of your Module1 (not within any subroutine/function):

Public NextTick as Date



NDBC wrote:

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.


--

Dave Peterson

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Incremental time values based upon clock in and clock out times saltnsnails Excel Discussion (Misc queries) 8 January 13th 09 08:11 PM
How do I calculate time in excel (clock in and clock out chad Excel Discussion (Misc queries) 3 January 7th 08 10:09 PM
Change EXCEL Clock to Standard Clock or Military Time YoMarie Excel Worksheet Functions 4 April 29th 07 08:39 PM
can excel be a time clock or stop watch? Anthony Reynard Chinnis New Users to Excel 1 February 15th 06 06:51 AM
Start Clock/Stop Clock abfabrob Excel Discussion (Misc queries) 9 June 28th 05 04:26 PM


All times are GMT +1. The time now is 12:28 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"