Public Declare Function SetTimer Lib "user32" (ByVal HWnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long
Public Declare Function KillTimer Lib "user32" (ByVal HWnd As Long, ByVal nIDEvent As Long) As Long
Public TimerID As Long
Public TimerSeconds As Single
Sub StartTimer()
TimerSeconds = 1 ' how often to "pop" the timer.
TimerID = SetTimer(0&, 0&, TimerSeconds * 1000&, AddressOf TimerProc)
End Sub
Sub EndTimer()
On Error Resume Next '使用错误控制语句忽略错误
KillTimer 0&, TimerID
End Sub
Sub TimerProc(ByVal HWnd As Long, ByVal uMsg As Long, ByVal nIDEvent As Long, ByVal dwTimer As Long)
Dim nColorS(5) As Integer
nColorS(0) = 3
nColorS(1) = 4
nColorS(2) = 5
nColorS(3) = 6
nColorS(4) = 7
intAll = intAll + 1
If intAll > 4 Then intAll = 0
Cells(1, 4).
网页链接 = nColorS(intAll) 'D1单元格每秒钟变换一次颜色
End Sub