Thread: time
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ozgur Pars[_2_] Ozgur Pars[_2_] is offline
external usenet poster
 
Posts: 70
Default time

Hi Zaahir,
I tried to do the same on my userform and was told that in order for the
label to get constantatly updated one has to call a procedure every second
here is the code I got from the internet...(it updates every 60 seconds so
if you want it to update every second change to 1 and change the format to
hh:mm:ss)

Regards,
Ozgur

Public RunWhen As Double
Public Const cRunIntervalSeconds = 60
Public Const cRunWhat = "The_Sub"

Sub StartTimer()
RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds)
Application.OnTime earliesttime:=RunWhen, procedu=cRunWhat, schedule:=True
End Sub


Sub The_Sub()
UserForm2.Label475.Caption = Format(Now, "dd mmm yy hh:mm")
UserForm2.Label476.Caption = Format(Now, "dd mmm yy hh:mm")
UserForm2.Label514.Caption = Format(Now, "dd mmm yy hh:mm")
Call StartTimer
End Sub


Sub StopTimer()
On Error Resume Next
Application.OnTime earliesttime:=RunWhen, procedu=cRunWhat,
schedule:=False
End Sub


"Zaahir" wrote:

hi

i want to make a clock using a label, but of i use the time & now values,
the result returned is the time at which the macro was run....
How do i get the a watch response out of the label, to give me hh:mm:ss
continuously?
Regards