下面的例子测试一下:Dim bolCancel As Boolean
Private Sub Command1_Click()
    bolCancel = False
    For i = 1 To 1000000
        Me.Caption = i
        If bolCancel Then Exit Sub
        DoEvents
    Next i
End SubPrivate Sub Command2_Click()
    bolCancel = True
End Sub