'close all sub forms
'Dim i As Integer
'For i = Forms.count - 1 To 1 Step -1
'    Unload Forms(i)
'Next用这个方法 编译出来的EXE文件关闭是会出VB.EXE的错误我记得VB中有个APPLICATION.CLOSE一类的十分方便的方法?

解决方案 »

  1.   

    end
    不过end 毕竟不太好
      

  2.   

    還有一個方法,記錄所有form.hwnd,再用api函數關閉
    不過,還不如end簡單,雖然效果不好
      

  3.   

    Dim Frm As form
    For each frm  in forms
        if not frm is me then Unload frm
    Next
      

  4.   

    Global.System.Windows.Forms.Application.Exit()
      

  5.   

    Dim Frm As form
    For each frm  in forms
        if not frm is me then Unload frm
    Next
      

  6.   

    是楼主的VB有问题(或系统有问题了吧)。
    我一直都在用这个代码,没有出现过LZ所说的问题
      

  7.   

    lz的VB没问题,那个代码的确是不能执行的
    有两种办法
    Dim Frm As form
    For each frm  in forms
        if not frm is me then Unload frm
    Next还有就是(这种方法不要在IDE调试,否则回关闭IDE)Dim lhWndTop As Long
            Dim lhWnd As Long
            lhWnd = Me.hwnd
            lhWndTop = lhWnd
            Do While Not (lhWnd = 0)
                lhWnd = GetWindow(lhWnd, GW_OWNER)
                If Not (lhWnd = 0) Then
                    lhWndTop = lhWnd
                End If
                SendMessage lhWndTop, WM_CLOSE, SC_CLOSE, SC_CLOSE        
      Loop
    里面的API和常量lz自己查吧