设计一个倒计时程序

来源:百度知道 编辑:UC知道 时间:2024/05/15 07:22:35
设计一个倒计时程序。要求: 通过inputbox 对话框输入倒计时时间(以分钟为单位),如100表示剩余01:40:00的时间;当倒计时时间到达00:00:00时,停止计时,并beep提示。
点击commamd1,弹出inputbox,输入时间后显示在label1中,点击command2,开始倒计时。

Dim Hours As Integer
Dim Minutes As Integer
Dim Seconds As Integer
Dim Time As Date

Private Sub Command2_Click()
Timer1.Enabled = True
End Sub

Private Sub Command1_Click()
Number = InputBox("输入倒计时时间,以秒为单位", "输入框", "100")
Hours = Number / 3600
Minutes = (Number - Hours * 3600) / 60
Seconds = (Number - Hours * 3600 - Minutes * 60)
Time = TimeSerial(Hours, Minutes, Seconds)
Label1.Caption = Format$(Time, "hh") & ":" & Format$(Time, "nn" _
)& ":" & Format$(Time, "ss")
End Sub
Private Sub Form_Load()
Form1.Top = (Screen.Height - Form1.Height) / 2
Form1.Left = (Screen.Width - Form1.Width) / 2
Timer1.Interval = 1000
Hours = 0
Minutes = 0
Seconds = 0
Time = 0
End Sub
Private Sub Timer1_Timer()
Timer1.Enabled = False
If (Format$(Time, "hh