如何通过一个按钮结束另一个按钮的运行!
如题:我的小程序有两个按钮,一个“开始”,一个“结束”。可是当点击“开始”后,再点击“结束”,程序并未按照“结束”的代码运行。
按钮是否有优先级可以设置,我想做的功能是:点击“结束”,“开始”中的程序停止运行,只运行“结束”中的程序。
求高手指点一二。
Option Explicit Dim Status As Boolean, i As Long Private Sub cmdCommand1_Click() Status = True: Timer1.Enabled = True End Sub Private Sub cmdCommand2_Click() Status = False: Timer1.Enabled = False End Sub Private Sub Form_Initialize() Status = False: i = 0 End Sub Private Sub Form_Load() Timer1.Enabled = False End Sub Private Sub Timer1_Timer() If Status = True Then i = i + 1 txtText1.Text = i DoEvents End If End Sub
Option Explicit Dim i As Long, j As Long Private Sub Command1_Click() Timer1.Enabled = True: Timer2.Enabled = False End Sub Private Sub Command2_Click() Timer1.Enabled = False: Timer2.Enabled = True End Sub Private Sub Form_Initialize() i = 0: j = 0 End Sub Private Sub Form_Load() Timer1.Enabled = False Timer2.Enabled = False End Sub Private Sub Timer1_Timer() If Timer1.Enabled = True Then i = i + 1 Text1.Text = i DoEvents End If End Sub Private Sub Timer2_Timer() If Timer2.Enabled = True Then j = j + 1 Text2.Text = j DoEvents End If End Sub