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
|