码迷,mamicode.com
首页 > 其他好文 > 详细

计时器

时间:2021-01-20 12:10:43      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:计时   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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!