我自己写的,不知道合不合你需要。 Dim a, b, c As Integer '开始按钮 Private Sub Command1_Click() Timer1.Enabled = True End Sub '停止按钮 Private Sub Command2_Click() Timer1.Enabled = False End Sub '归零按钮 Private Sub Command3_Click() Timer1.Enabled = False Text1.Text = 0 Text2.Text = 0 Text3.Text = 0 End SubPrivate Sub Form_Load() Text1.Text = 0 Text2.Text = 0 Text3.Text = 0 Timer1.Interval = 100 Timer1.Enabled = False End Sub Private Sub Timer1_Timer() Text3.Text = Text3.Text + 1 If Text3.Text = 10 Then Text2.Text = Text2.Text + 1 Text3.Text = 0 If Text2.Text = 10 Then Text1.Text = Text1.Text + 1 Text2.Text = 0 End If End If End Sub
刚才第一行多余的,可以删掉,我也是个菜鸟,呵呵。 下面是个最简单的: Private Sub Command1_Click() Timer1.Enabled = True End SubPrivate Sub Form_Load() Text1.Text = 0 Timer1.Interval = 100 Timer1.Enabled = False End Sub Private Sub Timer1_Timer() Text1.Text = Text1.Text + 1 End Sub
简单思路:
一个按钮控件来控制开始和停止,控制一个标志变量
一个循环记数,循环中判断标志变量,当该变量为真时开始记数,当该变量为假事停止记数并显示出记数值,其他还有一些细节,例如60进位什么的都是很容易解决的。不多罗嗦了。
http://www.programsalon.com/dl.asp?id=11633
Dim a, b, c As Integer
'开始按钮
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub
'停止按钮
Private Sub Command2_Click()
Timer1.Enabled = False
End Sub
'归零按钮
Private Sub Command3_Click()
Timer1.Enabled = False
Text1.Text = 0
Text2.Text = 0
Text3.Text = 0
End SubPrivate Sub Form_Load()
Text1.Text = 0
Text2.Text = 0
Text3.Text = 0
Timer1.Interval = 100
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
Text3.Text = Text3.Text + 1
If Text3.Text = 10 Then
Text2.Text = Text2.Text + 1
Text3.Text = 0
If Text2.Text = 10 Then
Text1.Text = Text1.Text + 1
Text2.Text = 0
End If
End If
End Sub
下面是个最简单的:
Private Sub Command1_Click()
Timer1.Enabled = True
End SubPrivate Sub Form_Load()
Text1.Text = 0
Timer1.Interval = 100
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
Text1.Text = Text1.Text + 1
End Sub