vb中,一个文本框,两个按钮设计一个简单的计时器,其中按钮分别为暂停和重置

2025-04-30 23:35:09
推荐回答(1个)
回答1:

Option Explicit
Private cc As Long

Private Sub Command1_Click()
    If Command1.Caption = "&S 暂停" Then
        Timer1.Enabled = False
        Command1.Caption = "&S 继续"
    Else
        Timer1.Enabled = True
        Command1.Caption = "&S 暂停"
    End If
End Sub

Private Sub Command2_Click()
    cc = 0
    Text1 = "0"
End Sub

Private Sub Form_Load()
    Timer1.Interval = 100
    Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
    cc = cc + 1
    Text1 = CStr(cc)
End Sub