标签:计时 timer mes public name rtti rgb interval app
VBA采用Application.OnTime实现计时器,代码如下:
Public RunWhen As Double Public Const cRunIntervalSeconds = 120 ‘ two minutes Public Const cRunWhat = "TheSub" ‘ the name of the procedure to run Sub StartTimer() RunWhen = Now + TimeSerial(0, 0, cRunIntervalSeconds) Application.OnTime EarliestTime:=RunWhen, Procedure:=cRunWhat, Schedule:=True Range("a1") = Time End Sub Sub TheSub() StartTimer ‘ Reschedule the procedure End Sub Sub StopTimer() On Error Resume Next Application.OnTime EarliestTime:=RunWhen, Procedure:=cRunWhat, Schedule:=False End Sub
标签:计时 timer mes public name rtti rgb interval app
原文地址:https://www.cnblogs.com/Stefan-Gao/p/14300788.html