找回密码
 立即注册
搜索

PPT VBA 倒计时和动态数字时钟

2
回复
534
查看
[复制链接]

24

主题

216

帖子

58

幻币

一流武者

Rank: 3Rank: 3

积分
276
QQ
2016-4-12 13:36:35 显示全部楼层 |阅读模式
Private Declare Function GetTickCount Lib "kernel32.dll" () As Long
Private 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 Long
Const InterVal = 1000
Private Sub CommandButton1_Click()
Static State, myStop As Boolean
Dim preTime, curTime, myTime, jsTime, txTime As Long
If State Then myStop = True: Exit Sub
CommandButton1.Caption = "Stop Counting"
State = True
preTime = GetTickCount
myTime = Val(TextBox2) + 1
jsTime = Val(TextBox2) + 2
txTime = Val(TextBox3)
Label3.Visible = False
Label4.Visible = False
TextBox2.Visible = False
TextBox3.Visible = False
Label2.Caption = "Counting..."
Do
curTime = GetTickCount
If curTime - preTime >= InterVal * (jsTime - myTime) Then
myTime = myTime - 1
TextBox1 = myTime
DoEvents
If myTime = txTime Then
Label2.Caption = "soon..."
Call PlaySound("Ding.wav", 0&)
End If
If myTime = 0 Then
State = False
myStop = False
CommandButton1.Caption = "Start Counting"
Call PlaySound("End.wav", 0&)
Exit Do
End If
End If
Sleep (20)
Label1 = Time
DoEvents
If myStop Then
State = False
myStop = False
CommandButton1.Caption = "Start counting"
MsgBox "Time up", vbInformation + vbOKOnly, "notice"
Exit Do
End If
Loop
Label2.Caption = "Time up!"
Label3.Visible = True
Label4.Visible = True
TextBox2.Visible = True
TextBox3.Visible = True
End Sub
PPT学习论坛
回复

使用道具 举报

14

主题

224

帖子

41

幻币

一流武者

Rank: 3Rank: 3

积分
283
QQ
2016-4-12 14:36:47 显示全部楼层
斑主,请上传附件,谢谢你
PPT学习论坛
回复 支持 反对

使用道具 举报

11

主题

205

帖子

39

幻币

一流武者

Rank: 3Rank: 3

积分
256
QQ
2016-4-12 17:47:01 显示全部楼层
哈哈,我需要附件
PPT学习论坛
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册