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
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