是不是这个意思?试试:
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Dim SUM As Long, BEPAUSE As Boolean
Private Sub Command1_Click()
If BEPAUSE = True Then BEPAUSE = False: Command1.Caption = "PAUSE": GETN
If BEPAUSE = False Then Command1.Caption = "RESTART": BEPAUSE = True
End Sub
Sub GETN()
Do While BEPAUSE = False
Sleep 200
DoEvents
SUM = SUM + 1
Me.Caption = SUM
Loop
End Sub
Private Sub Form_Load()
Command1.Caption = "START"
BEPAUSE = True
End Sub
Option Explicit
Dim WaitFlag As Boolean
Private Sub Command1_Click()
Dim i As Long
For i = 1 To 100000
DoEvents
If WaitFlag = True Then
Do While WaitFlag = True
DoEvents
Loop
End If
Me.Caption = CStr(i)
Next
End Sub
Private Sub Command2_Click()
WaitFlag = Not WaitFlag
End Sub