live time on userform or within frame

  • Thread starter Thread starter T.c.Goosen1977
  • Start date Start date
T

T.c.Goosen1977

Its easy to display the date and time in a userform but is it possible
to have the time, seconds, running live in the userform or frame...or
is it just the case of refreshing the update within the
frame/userform......mmm but how?

Thanks Theuns
 
Here is an example based upon a label on the form to show the time, and two
buttons, one to start it, one to stop it.

This is the userform code

Private Sub CommandButton1_Click()
DisplayTime
End Sub

Private Sub CommandButton2_Click()
Application.OnTime nTime, "DisplayTime", , False
End Sub

and in a standrad code module

Public nTime As Double

Sub DisplayTime()
UserForm1.Label1 = Format(Now(), "dd mmm yyyy hh:mm:ss")
nTime = Now() + TimeSerial(0, 0, 1)
Application.OnTime nTime, "DisplayTime"
End Sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"T.c.Goosen1977"
 
if i use your code bob it's working but it's only showing me the date
not the time?
 
make your textbox bigger, or edit the format so it shows what you want
 
Your textbox must be too small, the format outputs time as well.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"T.c.Goosen1977"
 
yes, you're right...the text box was to small...i see that the time is
current but not live...is it a lot more work to get the time running
live within the form..or do i need to install some special .dll time
file to make the second run live?
 
Funnily enough, I posted this earlier today

Here is an example based upon a label on the form to show the time, and two
buttons, one to start it, one to stop it.

This is the userform code

Private Sub CommandButton1_Click()
DisplayTime
End Sub

Private Sub CommandButton2_Click()
Application.OnTime nTime, "DisplayTime", , False
End Sub

and in a standrad code module

Public nTime As Double

Sub DisplayTime()
UserForm1.Label1 = Format(Now(), "dd mmm yyyy hh:mm:ss")
nTime = Now() + TimeSerial(0, 0, 1)
Application.OnTime nTime, "DisplayTime"
End Sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"T.c.Goosen1977"
 
Sorry about that, it was you I gave it to <vbg>

Are you saying the time isn't updating? I can't understand if so, the code
is all about that.

--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

Bob Phillips said:
Funnily enough, I posted this earlier today

Here is an example based upon a label on the form to show the time, and two
buttons, one to start it, one to stop it.

This is the userform code

Private Sub CommandButton1_Click()
DisplayTime
End Sub

Private Sub CommandButton2_Click()
Application.OnTime nTime, "DisplayTime", , False
End Sub

and in a standrad code module

Public nTime As Double

Sub DisplayTime()
UserForm1.Label1 = Format(Now(), "dd mmm yyyy hh:mm:ss")
nTime = Now() + TimeSerial(0, 0, 1)
Application.OnTime nTime, "DisplayTime"
End Sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"T.c.Goosen1977"
message news:[email protected]...
 

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

Back
Top