ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   clock on user form (https://www.excelbanter.com/excel-discussion-misc-queries/235743-clock-user-form.html)

NDBC

clock on user form
 
I have set up a user form (userform1) and would like to show the time on the
form in the textbox named clock1 as soon as the form is opened and have it
stay up the whole time until the form is closed. This is what I have tried.
It doesn't seem to do anything.

Sub RClock1()
Clock1.Text = CDbl(Time)

' Set up the next event one second from now
NextTick = Now + TimeValue("00:00:01")
Application.OnTime NextTick, "RClock1"
End Sub

I have the code in the code section for userform1.

Any ideas. Thanks

Jacob Skaria

clock on user form
 
Insert a module and paste the below code..

Sub Main()
Load UserForm1
UserForm1.Show
End Sub


In Code section of Userform

Private Sub UserForm_Activate()
RClock1
End Sub


Sub RClock1()
UserForm1.Clock1.Text = Format(Now, "hh:mm:ss")
UserForm1.Repaint
NextTick = Now + TimeValue("00:00:01")
Application.OnTime NextTick, "RClock1"
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"NDBC" wrote:

I have set up a user form (userform1) and would like to show the time on the
form in the textbox named clock1 as soon as the form is opened and have it
stay up the whole time until the form is closed. This is what I have tried.
It doesn't seem to do anything.

Sub RClock1()
Clock1.Text = CDbl(Time)

' Set up the next event one second from now
NextTick = Now + TimeValue("00:00:01")
Application.OnTime NextTick, "RClock1"
End Sub

I have the code in the code section for userform1.

Any ideas. Thanks


NDBC

clock on user form
 
Jacob,

I did what you said. It gets the time into the textbox (a lot more than I
could do) but it does not change. The time just stays at the time you start
the form it does not tick. Any more ideas.

Thanks

"Jacob Skaria" wrote:

Insert a module and paste the below code..

Sub Main()
Load UserForm1
UserForm1.Show
End Sub


In Code section of Userform

Private Sub UserForm_Activate()
RClock1
End Sub


Sub RClock1()
UserForm1.Clock1.Text = Format(Now, "hh:mm:ss")
UserForm1.Repaint
NextTick = Now + TimeValue("00:00:01")
Application.OnTime NextTick, "RClock1"
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"NDBC" wrote:

I have set up a user form (userform1) and would like to show the time on the
form in the textbox named clock1 as soon as the form is opened and have it
stay up the whole time until the form is closed. This is what I have tried.
It doesn't seem to do anything.

Sub RClock1()
Clock1.Text = CDbl(Time)

' Set up the next event one second from now
NextTick = Now + TimeValue("00:00:01")
Application.OnTime NextTick, "RClock1"
End Sub

I have the code in the code section for userform1.

Any ideas. Thanks


Jacob Skaria

clock on user form
 
Oops..

In the module paste the below code..

Sub Macro1()
Load UserForm1
UserForm1.Show
End Sub

Sub RClock1()
UserForm1.Clock1.Text = Format(Now, "hh:mm:ss")
UserForm1.Repaint
NextTick = Now + TimeValue("00:00:01")
Application.OnTime NextTick, "RClock1"
End Sub

In Code section of Userform..paste the below

Private Sub UserForm_Activate()
Call RClock1
End Sub

and run macro1 from MacroList


If this post helps click Yes
---------------
Jacob Skaria


"NDBC" wrote:

Jacob,

I did what you said. It gets the time into the textbox (a lot more than I
could do) but it does not change. The time just stays at the time you start
the form it does not tick. Any more ideas.

Thanks

"Jacob Skaria" wrote:

Insert a module and paste the below code..

Sub Main()
Load UserForm1
UserForm1.Show
End Sub


In Code section of Userform

Private Sub UserForm_Activate()
RClock1
End Sub


Sub RClock1()
UserForm1.Clock1.Text = Format(Now, "hh:mm:ss")
UserForm1.Repaint
NextTick = Now + TimeValue("00:00:01")
Application.OnTime NextTick, "RClock1"
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"NDBC" wrote:

I have set up a user form (userform1) and would like to show the time on the
form in the textbox named clock1 as soon as the form is opened and have it
stay up the whole time until the form is closed. This is what I have tried.
It doesn't seem to do anything.

Sub RClock1()
Clock1.Text = CDbl(Time)

' Set up the next event one second from now
NextTick = Now + TimeValue("00:00:01")
Application.OnTime NextTick, "RClock1"
End Sub

I have the code in the code section for userform1.

Any ideas. Thanks


NDBC

clock on user form
 
Jacob,

Worked a treat but I did not tell you the full story as I thought the
changes required would be easy. Should have known. What I really want is the
time since the race started in the text box. This is equal to Now - start
time. The start time is stored in cell b6 in sheet "Timing Sheet". This is
what I thought would work

Sub RClock1()
Watch = Now - sheets("timing sheet").cell("b6")
UserForm1.Clock1.Text = Format(Watch, "hh:mm:ss")
UserForm1.Repaint
NextTick = Now + TimeValue("00:00:01")
Application.OnTime NextTick, "RClock1"
End Sub


I should have known it wouldn't be that easy. Yet again, please show me how
to fix it.

Thanks


"Jacob Skaria" wrote:

Oops..

In the module paste the below code..

Sub Macro1()
Load UserForm1
UserForm1.Show
End Sub

Sub RClock1()
UserForm1.Clock1.Text = Format(Now, "hh:mm:ss")
UserForm1.Repaint
NextTick = Now + TimeValue("00:00:01")
Application.OnTime NextTick, "RClock1"
End Sub

In Code section of Userform..paste the below

Private Sub UserForm_Activate()
Call RClock1
End Sub

and run macro1 from MacroList


If this post helps click Yes
---------------
Jacob Skaria


"NDBC" wrote:

Jacob,

I did what you said. It gets the time into the textbox (a lot more than I
could do) but it does not change. The time just stays at the time you start
the form it does not tick. Any more ideas.

Thanks

"Jacob Skaria" wrote:

Insert a module and paste the below code..

Sub Main()
Load UserForm1
UserForm1.Show
End Sub


In Code section of Userform

Private Sub UserForm_Activate()
RClock1
End Sub


Sub RClock1()
UserForm1.Clock1.Text = Format(Now, "hh:mm:ss")
UserForm1.Repaint
NextTick = Now + TimeValue("00:00:01")
Application.OnTime NextTick, "RClock1"
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"NDBC" wrote:

I have set up a user form (userform1) and would like to show the time on the
form in the textbox named clock1 as soon as the form is opened and have it
stay up the whole time until the form is closed. This is what I have tried.
It doesn't seem to do anything.

Sub RClock1()
Clock1.Text = CDbl(Time)

' Set up the next event one second from now
NextTick = Now + TimeValue("00:00:01")
Application.OnTime NextTick, "RClock1"
End Sub

I have the code in the code section for userform1.

Any ideas. Thanks


NDBC

clock on user form
 
Got it to work.

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

Cracked it. Thank you.

"NDBC" wrote:

Jacob,

Worked a treat but I did not tell you the full story as I thought the
changes required would be easy. Should have known. What I really want is the
time since the race started in the text box. This is equal to Now - start
time. The start time is stored in cell b6 in sheet "Timing Sheet". This is
what I thought would work

Sub RClock1()
Watch = Now - sheets("timing sheet").cell("b6")
UserForm1.Clock1.Text = Format(Watch, "hh:mm:ss")
UserForm1.Repaint
NextTick = Now + TimeValue("00:00:01")
Application.OnTime NextTick, "RClock1"
End Sub


I should have known it wouldn't be that easy. Yet again, please show me how
to fix it.

Thanks


"Jacob Skaria" wrote:

Oops..

In the module paste the below code..

Sub Macro1()
Load UserForm1
UserForm1.Show
End Sub

Sub RClock1()
UserForm1.Clock1.Text = Format(Now, "hh:mm:ss")
UserForm1.Repaint
NextTick = Now + TimeValue("00:00:01")
Application.OnTime NextTick, "RClock1"
End Sub

In Code section of Userform..paste the below

Private Sub UserForm_Activate()
Call RClock1
End Sub

and run macro1 from MacroList


If this post helps click Yes
---------------
Jacob Skaria


"NDBC" wrote:

Jacob,

I did what you said. It gets the time into the textbox (a lot more than I
could do) but it does not change. The time just stays at the time you start
the form it does not tick. Any more ideas.

Thanks

"Jacob Skaria" wrote:

Insert a module and paste the below code..

Sub Main()
Load UserForm1
UserForm1.Show
End Sub


In Code section of Userform

Private Sub UserForm_Activate()
RClock1
End Sub


Sub RClock1()
UserForm1.Clock1.Text = Format(Now, "hh:mm:ss")
UserForm1.Repaint
NextTick = Now + TimeValue("00:00:01")
Application.OnTime NextTick, "RClock1"
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"NDBC" wrote:

I have set up a user form (userform1) and would like to show the time on the
form in the textbox named clock1 as soon as the form is opened and have it
stay up the whole time until the form is closed. This is what I have tried.
It doesn't seem to do anything.

Sub RClock1()
Clock1.Text = CDbl(Time)

' Set up the next event one second from now
NextTick = Now + TimeValue("00:00:01")
Application.OnTime NextTick, "RClock1"
End Sub

I have the code in the code section for userform1.

Any ideas. Thanks


Jacob Skaria

clock on user form
 
I am not sure how this will affect your other routines. This should work

Sub RClock1()
Watch = Now - Sheets("timing sheet").Range("b6")
UserForm1.Clock1.Text = Format(Watch, "hh:mm:ss")
Application.OnTime Now + TimeValue("00:00:01"), "RClock1"
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"NDBC" wrote:

Jacob,

Worked a treat but I did not tell you the full story as I thought the
changes required would be easy. Should have known. What I really want is the
time since the race started in the text box. This is equal to Now - start
time. The start time is stored in cell b6 in sheet "Timing Sheet". This is
what I thought would work

Sub RClock1()
Watch = Now - sheets("timing sheet").cell("b6")
UserForm1.Clock1.Text = Format(Watch, "hh:mm:ss")
UserForm1.Repaint
NextTick = Now + TimeValue("00:00:01")
Application.OnTime NextTick, "RClock1"
End Sub


I should have known it wouldn't be that easy. Yet again, please show me how
to fix it.

Thanks


"Jacob Skaria" wrote:

Oops..

In the module paste the below code..

Sub Macro1()
Load UserForm1
UserForm1.Show
End Sub

Sub RClock1()
UserForm1.Clock1.Text = Format(Now, "hh:mm:ss")
UserForm1.Repaint
NextTick = Now + TimeValue("00:00:01")
Application.OnTime NextTick, "RClock1"
End Sub

In Code section of Userform..paste the below

Private Sub UserForm_Activate()
Call RClock1
End Sub

and run macro1 from MacroList


If this post helps click Yes
---------------
Jacob Skaria


"NDBC" wrote:

Jacob,

I did what you said. It gets the time into the textbox (a lot more than I
could do) but it does not change. The time just stays at the time you start
the form it does not tick. Any more ideas.

Thanks

"Jacob Skaria" wrote:

Insert a module and paste the below code..

Sub Main()
Load UserForm1
UserForm1.Show
End Sub


In Code section of Userform

Private Sub UserForm_Activate()
RClock1
End Sub


Sub RClock1()
UserForm1.Clock1.Text = Format(Now, "hh:mm:ss")
UserForm1.Repaint
NextTick = Now + TimeValue("00:00:01")
Application.OnTime NextTick, "RClock1"
End Sub

If this post helps click Yes
---------------
Jacob Skaria


"NDBC" wrote:

I have set up a user form (userform1) and would like to show the time on the
form in the textbox named clock1 as soon as the form is opened and have it
stay up the whole time until the form is closed. This is what I have tried.
It doesn't seem to do anything.

Sub RClock1()
Clock1.Text = CDbl(Time)

' Set up the next event one second from now
NextTick = Now + TimeValue("00:00:01")
Application.OnTime NextTick, "RClock1"
End Sub

I have the code in the code section for userform1.

Any ideas. Thanks



All times are GMT +1. The time now is 08:39 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com