Declare PtrSafe Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As LongPtr) As Long
Declare PtrSafe Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long
Public mTimer As Long
'计时函数,每一秒钟运行一次
Sub timer()
ss = DateDiff("s", Now, "2023-2-1 00:00:00")
dd = ss \ 86400
hh = (ss Mod 86400) \ 3600
mm = (ss Mod 3600) \ 60
ss = ss Mod 60
Slide1.Label1.Caption = dd & " 天 " & hh & " 小时 " & mm & " 分 " & ss & " 秒"
End Sub
'1s调用一次timer函数计算间隔时间
Sub start()
mTimer = SetTimer(0, 0, 1000, AddressOf timer)
End Sub
'PPT开始展示时,调用start函数,开始显示计时
Sub OnSlideShowPageChange()
Call start
End Sub
'PPT终止演示时,结束计时
Sub OnSlideShowTerminate()
mTimer = KillTimer(0, mTimer)
End Sub