用VB设计一个倒计时器,能够设置倒计时的时间,并进行倒计时

请给出完整代码,运用哪些控件 谢谢

Dim 时 As Integer, 分 As Integer, 秒 As Integer
Dim 终止时间 As Date
Private Sub Command1_Click()
时 = CInt(InputBox("请输入计时小时数<24"))
分 = CInt(InputBox("请输入计时分钟数0-59"))
秒 = CInt(InputBox("请输入计时秒数0-59"))
End Sub

Private Sub Command2_Click()
Timer1.Enabled = True
终止时间 = Now() + (((秒 / 60) + 分) / 60 + 时) / 24
Timer1_Timer
Command2.Enabled = False
Command3.Enabled = True
End Sub

Private Sub Command3_Click()
Timer1.Enabled = False
Command2.Enabled = True
Command3.Enabled = False
End Sub

Private Sub Form_Load()
Command1.Caption = "设置计时时长"
Command2.Caption = "开始"
Command3.Caption = "停止"
Timer1.Enabled = False
Timer1.Interval = 1000
End Sub

Private Sub Timer1_Timer()
Dim 剩余时间 As Date
剩余时间 = 终止时间 - Now()
If 剩余时间 < 0 Then
Command3.Value = True
Label1 = "计时时间已经到了!"
Else
Label1 = 剩余时间
End If
End Sub

三个按钮、一个标签。
温馨提示:答案为网友推荐,仅供参考
第1个回答  2019-01-03
Option
Explicit
Dim
SetTime
As
Integer
Private
Sub
Command1_Click()
Timer1.Interval
=
1000
SetTime
=
CInt(Text1)
Timer1.Enabled
=
True
End
Sub
Private
Sub
Timer1_Timer()
SetTime
=
SetTime
-
1
If
SetTime
=
0
Then
MsgBox
"时间到"
End
If
End
Sub
text1里面输入倒计时时间(秒),command1开始倒计时
相似回答