PDA

View Full Version : Application.ontime discover



Daniel2001
02-05-2008, 12:47 AM
Hi everybody!

I found a thing about Ontime.. it seems it works fine with minutes and seconds,but not Hour. The following simple code is just record the time everytime it runs .The loop is set to be 1 hour. which means every hour, the Count() runs and records the current time into the cells. When I set ontime now+("00:00:10"),it executes perfectly as I expected. The result looks like the following:

23:54:09
23:54:19
23:54:29
23:54:39
23:54:49

However, when I set the ontime now+("01:00:00"), the result is

2:36:04
2:55:26
2:55:53
3:36:04
3:55:26
3:55:53

so It runs several times during one hour!!!!
PLEASE give some help and advice...I am really stuck here...:dunno
Thanks very very much!!!!!!!

-----------------------------------------------------
'here is the code

Dim x As String
Dim y As String
Dim i As Integer

Sub initializer()
i = 1
y = "b1"
Call count
End Sub

Sub starttimer()
Application.OnTime now+TimeValue("01:00:00"), "count"
End Sub

Sub count()
Range(y) = Format(Now(), "hh:mm:ss")
i = i + 1
y = "b" & i
call starttimer

End Sub

Bob Phillips
02-05-2008, 02:21 AM
I am running this and it seems to be behaving impeccably to me.

First at 8:05, second at 9:05. Will upodate with later times.

I bet it is your multiple ontimes, which you have mentioned in other threads, which is causing the problem, no bug in OnTime.