比如我现在正在用一个循环把外部数据逐条导入到程序的数据库中
然后再窗体上添加一个终止按钮
这个按钮代码应该如何写才能让程序跳出循环

解决方案 »

  1.   


    Private bolStop As BooleanPrivate Sub Command1_Click()
    Dim i As Long
    For i = 0 To 100000    '这里是你的循环逻辑
        '
        '
        '''''''''''''''''
        DoEvents
        If bolStop Then
            bolStop = False
            Exit For
        End If
    Next
    End Sub
    Private Sub Command2_Click()
        bolStop = True
    End Sub
      

  2.   

    dim f as boolean
    sub command1_click()
       f=true
    end subsub DataToDataBase()
        .
        .
        while not 数据已经倒完 and not f
              .
              .
              导数据
       wendens sub