仪器社区

vb怎么设计简单的计时器

aaa一辈子4 2011-05-23
用vb中的timer控件,设计计时器。用三个命令按钮,分别为:开始、暂停、结束。再用一个标签或者文本框显示就好了。 各位大侠教教,我初学。
评论
全部评论
liguozheng2006
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
Label1.Caption = 0
End Sub

Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 1000
s = 0
Label1.Caption = s
End Sub

Private Sub Timer1_Timer()
s = Label1.Caption
s = s + 1
Label1.Caption = s
End Sub
1 0 2011-05-24 0条评论 回复
WonDinZN
Dim nCount As Long

Private Sub cmdPause_Click()
Timer1.Enabled = False

End Sub

Private Sub cmdStart_Click()
Timer1.Enabled = True

End Sub

Private Sub cmdStop_Click()
Timer1.Enabled = False
nCount = 0
Label1.Caption = Format(nCount)

End Sub

Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 1000
nCount = 0
Label1.Caption = Format(nCount)
End Sub

Private Sub Timer1_Timer()
nCount = nCount + 1
Label1.Caption = Format(nCount)
End Sub
16 0 2011-05-31 0条评论 回复
您可能感兴趣的社区主题
加载中...
发布 评论