Excel vba的问题:如何用settimer和killtimer写一个代码
发布网友
发布时间:2022-06-09 17:43
我来回答
共1个回答
热心网友
时间:2024-12-15 02:24
Declare Function SetTimer Lib "user32" _
(ByVal hwnd As Long, _
ByVal nIDEvent As Long, _
ByVal uElapse As Long, _
ByVal lpTimerFunc As Long) As Long
Declare Function KillTimer Lib "user32" _
(ByVal hwnd As Long, _
ByVal nIDEvent As Long) As Long
Public lngTimerID As Long
Sub g(ByVal hwnd As Long, _
ByVal uMsg As Long, _
ByVal idEvent As Long, _
ByVal dwTime As Long)
xx = Int(Rnd * 10 + 3)
[a1].Interior.ColorIndex = xx
If xx = 3 Then lngTimerID = KillTimer(0, lngTimerID)
End Sub
Sub mystart()
lngTimerID = SetTimer(0, 0, 1000, AddressOf g)
End Sub
追问运行不成功,有编译错误。