vb2010,计算时间的问题,我想点一下button1就开始计时,在form显示时间,再点一下button2就结束计时。

2024-11-07 11:02:26
推荐回答(1个)
回答1:

采用颤兆Timer控察肢件,设置Timer1.Interval = 0
当点击button1时,Timer1.Interval = 1000 (1000=1秒)
直接给你代败洞世码吧

Dim a As Long
Private Sub Command1_Click()
If Timer1.Interval = 1000 Then
Timer1.Interval = 0
MsgBox "经过了" & CStr(a) & 秒钟
Else
Timer1.Interval = 1000
End If
a = 0
End Sub

Private Sub Timer1_Timer()
Label1.Caption = Time
a = a + 1
End Sub