Private Sub Form_Load() Command1.Caption = "开始" Command2.Caption = "停止" Dim h As String Dim m As String Dim s As String h = 0 m = 0 s = 0 Timer1.Enabled = False Timer1.Interval = 1000 Label1.Caption = "00:00:00" End Sub Private Sub Command1_Click() Command1.Enabled = False Timer1.Enabled = True End Sub Private Sub Command2_Click() Timer1.Enabled = False Label1.Caption = "00:00:00" End Sub Private Sub Timer1_Timer() s = s + 1 If s = 60 Then m = m + 1 s = 0 ElseIf m = 60 Then h = h + 1 m = 0 End If Label1.Caption = Format(h, "00") & ":" & Format(m, "00") & ":" & Format(s, "00") End Sub
以上代码还有很多问题还没有解决,正在调试中……谁帮看看错误在哪里?
窗体上有:command1 command2 timer1 label1等控件。
變量定義,不能使string,應該是int
我觉得让别人看你的代码的话,是不是先把格式调整好,什么缩进了之类的,这样看着也方便点。