在網路上找到一個可以顯示在工作頁的計時器, 想跟自己寫的東西並行, 卻發現會一直在計時的程式跑, 請問.....這種方式可行嗎?
sub xx
...............
k = Timer / 86400 + 0.001 / 86400
Application.OnTime k, "yy"
................
end sub
計時器
Public StopIt As Boolean
Public ResetIt As Boolean
Public LastTime
Sub yy()
Dim StartTime, FinishTime, TotalTime, PauseTime
StopIt = False
ResetIt = False
If Range("a18") = 0 Then
StartTime = Timer
PauseTime = 0
LastTime = 0
Else
StartTime = 0
PauseTime = Timer
End If
StartIt:
DoEvents
If StopIt = True Then
LastTime = TotalTime
Exit Sub
Else
FinishTime = Timer
TotalTime = FinishTime - StartTime + LastTime - PauseTime
TTime = TotalTime * 100
Hm = TTime Mod 100
TTime = TTime \ 100
hh = TTime \ 3600
TTime = TTime Mod 3600
MM = TTime \ 60
SS = TTime Mod 60
Range("a18").Value = Format(hh, "00") & ":" & Format(MM, "00") & ":" & Format(SS, "00") & "." & Format(Hm, "00")
If ResetIt = True Then
Range("a18") = Format(0, "00") & ":" & Format(0, "00") & ":" & Format(0, "00") & "." & Format(0, "00")
LastTime = 0
PauseTime = 0
End
End If
GoTo StartIt
End If
End Sub作者: Hsieh 時間: 2012-3-14 08:18