1、在窗体上添加一个label1控件
2、在窗体上添加一个command1控件
3、在窗体上添加一个timer1控件
4、复制如下代码,运行
Dim a As Long
Private Sub Command1_Click()
a = InputBox("请输入秒数")
Label1.Caption = a
Timer1.Enabled = True
End Sub
Private Sub Form_Load()
Timer1.Interval = 1000
Timer1.Enabled = False
Command1.Caption = "记时开始"
End Sub
Private Sub Timer1_Timer()
a = a - 1
Label1.Caption = a
Print a
If a = 0 Then
Timer1.Enabled = False
End If
End Sub