|
楼主 |
发表于 2011-6-9 20:30
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
回复 187楼 sunsoncheng 的帖子
要用到类的事件的话,还是需要在类模块(包括窗体,工作表模块)里使用。
在标准模块里使用定时器的话,你应该知道使用Application.onTime
如果觉得用递归比较麻烦的话,也可以用API函数来实现同样的onTime功能。- Private Declare Function SetTimer Lib "user32.dll" (ByVal hwnd As Long, ByVal nIDEvent As Long, _
- ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
- Private Declare Function KillTimer Lib "user32.dll" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long
- Public lTimerID As Long
- Sub StartTimer(lDuration As Long)
- If lTimerID = 0 Then
- lTimerID = SetTimer(0&, 0&, lDuration, AddressOf OnTime)
- Else
- Call StopTimer
- lTimerID = SetTimer(0&, 0&, lDuration, AddressOf OnTime)
- End If
- End Sub
- Sub StopTimer()
- KillTimer 0&, lTimerID
- End Sub
- Sub OnTime()
- Cells(1, 1) = Now
- End Sub
复制代码
[ 本帖最后由 winland 于 2011-6-9 20:32 编辑 ] |
|