Java81883
lostfalling
采纳率67.6%
2019-06-30 14:01 阅读 449

vba 当触发KillTimer时,excel直接闪退了,连看代码出错的的时间都没有,敢问大神原因?

20

```Public Declare PtrSafe Function SetTimer Lib "user32" ( _
    ByVal HWnd As Long, _
    ByVal nIDEvent As Long, _
    ByVal uElapse As Long, _
    ByVal lpTimerFunc As LongPtr) As Long

Public Declare PtrSafe Function KillTimer Lib "user32" ( _
    ByVal HWnd As Long, _
    ByVal nIDEvent As LongPtr) As Long

Public Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)

Public TimerID As Long
Public mymy As Integer
Sub StartTimer()
    TimerID = SetTimer(0&, 0&, 50&, AddressOf TimerProc)
    DoEvents
End Sub

Sub EndTimer()'触直接excel闪退
    On Error Resume Next
    KillTimer 0&, TimerID
End Sub
Sub TimerProc()
    mymy = mymy + 1
    Sheet1.Cells(5, 5) = mymy
End Sub
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

相关推荐