谁能让这个程序立刻关闭
Private Sub Command1_Click()
Unload Me    '这里如果是end就立刻关闭窗体了
End SubPrivate Sub Timer1_Timer()
Dim i As Long
For i = 1 To 1000
Label1.Caption = i
Delay 10
Next
End Sub
Public Sub Delay(mSec As Long)
    On Error GoTo ShowErr
    
    Dim TStart  As Single
    
    TStart = Timer
    
    While (Timer - TStart) < (mSec / 1000)
        DoEvents
    Wend
    Exit Sub
ShowErr:
    MsgBox Err.Source & "------" & Err.Description
    Exit SubEnd Sub

解决方案 »

  1.   

    或者TerminateProcess
    或者这样…… - -bPrivate Sub Form_Unload(Cancel As Integer)
        End
    End Sub
      

  2.   

    你到底是要立即关闭还是不要立即关闭阿,立即关闭用END就可以了.
      

  3.   

    '加一指示变量RunEnabledPrivate RunEnabled As Boolean
    Private Sub Command1_Click()
        RunEnabled = False
    End SubPrivate Sub Form_Load()
        RunEnabled = True
    End SubPrivate Sub Timer1_Timer()
        Dim i As Long
        For i = 1 To 1000
        If RunEnabled Then
            Label1.Caption = i
            Delay 100
        End If
        Next
    End Sub
    Public Sub Delay(mSec As Long)
        On Error GoTo ShowErr
        
        Dim TStart  As Single
        Debug.Print ".";
        TStart = Timer
        While (Timer - TStart) < (mSec / 1000)
            DoEvents
        Wend
        Exit Sub
    ShowErr:
        MsgBox Err.Source & "------" & Err.Description
        Exit SubEnd Sub