使用Office2003 VBA制作有倒计时功能的PPT

点击图示,拖动按钮到界面上

拖到界面的按钮上点右键,选择“属性”

在Caption输入“开始倒计时”

如下图所示,再拖动几个控件到界面上

在按钮上点右键,,选择“查看代码”(或按键Alt+F11,打开VBA编程环境,后双击Slide1)

ff输入代码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 = "停止倒计时"State = TruepreTime = GetTickCountmyTime = Val(TextBox2) + 1jsTime = Val(TextBox2) + 2txTime = Val(TextBox3)Label3.Visible = FalseLabel4.Visible = FalseTextBox2.Visible = FalseTextBox3.Visible = FalseLabel2.Caption = "计时进行中"DocurTime = GetTickCountIf curTime – preTime >= InterVal * (jsTime – myTime) ThenmyTime = myTime – 1TextBox1 = myTimeDoEventsIf myTime = txTime ThenLabel2.Caption = "计时将结束"' Call PlaySound("Ding.wav", 0&)End IfIf myTime = 0 ThenState = FalsemyStop = FalseCommandButton1.Caption = "开始倒计时"' Call PlaySound("End.wav", 0&)Exit DoEnd IfEnd IfSleep (20)Label1 = TimeDoEventsIf myStop ThenState = FalsemyStop = FalseCommandButton1.Caption = "开始倒计时"MsgBox "倒计时终止!", vbInformation + vbOKOnly, "操作提示"Exit DoEnd IfLoopLabel2.Caption = "计时时间到"Label3.Visible = TrueLabel4.Visible = TrueTextBox2.Visible = TrueTextBox3.Visible = TrueEnd Sub保存后,按Shift+F5 , 演示。在请输入倒计时时间(秒)填入60,在倒计时结束前提醒(秒)填入5,点击“开始倒计时”按钮。

对于沙漠中的旅行者,最可怕的不是眼前无尽的荒漠,而是心中没有绿洲。

使用Office2003 VBA制作有倒计时功能的PPT

相关文章:

你感兴趣的文章:

标签云: