定义全局变量(在模块)
Public ChildForms As New Collection
然后每个窗体写:
Private Sub Form_Initialize()
    ChildForms.Add Me
End Sub
你也可以生成一个集合,让它只能放窗体

解决方案 »

  1.   

    但是这样不方便,特别是在某一个子窗体卸载以后用ChildForms.Remove方法不能很好的移除这个元素。还有别的办法吗?
      

  2.   

    使用Forms,可以
    dim xForm as Form
    Form each xForm in Forms    msgbox xform.captionnext
      

  3.   

    以下代码是把非 MDI 的窗口关闭:
    Private Sub showNew()
        Dim i As Integer
        For i = 0 To Forms.Count - 1
            If Forms(i).Name <> "系统主菜单" Then
                Unload Forms(i)
                If Forms.Count = 1 Then
                    Exit For
                End If
            End If
            i = 0
        Next i
    End Sub