创建3个按钮,用默认名字命名
创建一个label控件,名称为label1
创建一个timer控件,名称为timer1
复制下列代码运行即可
Private a As Long
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
Private Sub Command2_Click()
Timer1.Enabled = False
End Sub
Private Sub Command3_Click()
a = 0
End Sub
Private Sub Form_Load()
Command1.Caption = "启动"
Command2.Caption = "停止"
Command3.Caption = "重新开始"
Label1.Caption = ""
Timer1.Enabled = 0
Timer1.Interval = 1000 '设定周期为1秒
End Sub
Private Sub Timer1_Timer()
a = a + 1
Label1.Caption = a
End Sub