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
三个按钮、一个标签。
温馨提示:答案为网友推荐,仅供参考