PPT中利用VBA显示时间
来源:百度知道 编辑:UC知道 时间:2024/06/10 20:27:16
转帖:
如下的方法请参考:
'这个脚本实线实时的数字时钟和指定时长的倒数计时
Private Declare Function GetTickCount Lib "kernel32.dll" () As LongPrivate Declare Sub Sleep Lib "kernel32.dll" (ByVal dwMilliseconds As Long)Private Declare Function PlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszName As String, ByVal uFlags As Long) As LongConst InterVal = 1000
Private Sub CommandButton1_Click()Static State, myStop As BooleanDim preTime, curTime, myTime, jsTime, txTime As LongIf State Then myStop = True: Exit SubCommandButton1.Caption = "Stop Counting"State = TruepreTime = GetTickCountmyTime = Val(TextBox2) + 1jsTime = Val(TextBox2) + 2txTime = Val(TextBox3)Label3.Visible = FalseLabel4.Visible = FalseTextBox2.Visible = FalseTextBox3.Visible = FalseLabel2.Caption = "Counting..."Do curTime = GetTickCount If curTime - preTime >= InterVal * (jsTime - myTime) Then myTime = myTime - 1 TextBox1 = myTime DoEv