Declare PtrSafe Function SetTimer Declare PtrSafe Function KillTime Public mTimer As Long
'计时函数,每一秒钟运行一次
Sub timer ()
ss = DateDiff (" s ","2020-6-110 dd = ss \86400
hh =( ss Mod 86400)\3600 mm =( ss Mod 3600)\60
SS = SS Mod 60
Slide1.Label1.Caption= dd &
End Sub
'1s调用一次 timer 函数计算间隔时间
Sub start ()
mTimer = SetTimer (0,0,1000,
End Sub
' PPT 开始展示时,调用 start 函数,开始显
Sub OnSlideShowPageChange ()
Call start End Sub
' PPT 终止演示时,结束计时
Sub OnSlideShowTerminate ()
mTimer = KillTimer (0, mTimer ) End Sub
大致是这个
5条回答 默认 最新
- 「已注销」 2023-03-09 03:16关注
“Devil组”引证GPT后的撰写:
修改:#If VBA7 Then Declare PtrSafe Function SetTimer Lib "user32" (ByVal HWnd As LongPtr, _ ByVal nIDEvent As LongPtr, ByVal uElapse As Long, _ ByVal lpTimerFunc As LongPtr) As LongPtr Declare PtrSafe Function KillTimer Lib "user32" (ByVal HWnd As LongPtr, _ ByVal nIDEvent As LongPtr) As Long #Else 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 #End If Public mTimer As Long ' 计时函数,每一秒钟运行一次 Sub timer() Dim elapsedTime As Long Dim days As Long, hours As Long, minutes As Long, seconds As Long elapsedTime = DateDiff("s", "2020-6-11", Now()) days = elapsedTime \ 86400 hours = (elapsedTime Mod 86400) \ 3600 minutes = (elapsedTime Mod 3600) \ 60 seconds = elapsedTime Mod 60 ActiveWindow.View.Slide.Master.Shapes("TextBox1").TextFrame.TextRange.Text = "Elapsed Time: " & _ days & " days " & Format(hours, "00") & ":" & Format(minutes, "00") & ":" & Format(seconds, "00") End Sub ' 1 s 调用一次 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
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报