![]() |
#2
wube2012-05-01 00:23
|
窗体上有:command1 command2 timer1 label1
以下是我自己写的代码:

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
有错误。
[ 本帖最后由 yuma 于 2012-4-29 16:21 编辑 ]