Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    Dim tmpfrm As Form
    For Each tmpfrm In Forms
        If tmpfrm.hwnd <> Me.hwnd Then
            Unload tmpfrm
            Set tmpfrm = Nothing
        End If
    Next
End SubPrivate Sub Form_Unload(Cancel As Integer)
    Set Me = Nothing
End Sub

解决方案 »

  1.   

    Private Sub Form_Unload(Cancel As Integer, UnloadMode As Integer)
        Dim tmpfrm As Form
        For Each tmpfrm In Forms
                        Unload tmpfrm
                Set tmpfrm = Nothing
               Next
    End Sub
    '你只是Unload窗体,又没做别的,没必要两个过程
      

  2.   

    Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
        Dim tmpfrm As Form
        For Each tmpfrm In Forms
            If tmpfrm.hwnd <> Me.hwnd Then
                Unload tmpfrm
                Set tmpfrm = Nothing
            End If
        Next
    End Sub
    这个就够了