Results 1 to 5 of 5

Thread: Unloading forms

  1. #1

    Thread Starter
    Hyperactive Member Gimpster's Avatar
    Join Date
    Oct 1999
    Location
    Redmond, WA 98052
    Posts
    331

    Post

    I was wondering if there is a quick and easy way to unload all of my MDI Child forms.

    ------------------
    Ryan

  2. #2
    So Unbanned DiGiTaIErRoR's Avatar
    Join Date
    Apr 1999
    Location
    /dev/null
    Posts
    4,111

    Post

    You could make the forms an array then:
    For x = 1 to 5
    Unload MChild(x)
    Next x
    or make a sub
    Public Sub UnloadM()
    Unload Mchild
    Unload Mchild2
    Unload Mchild3
    End Sub

    ------------------
    DiGiTaIErRoR
    VB, QBasic, Iptscrae, HTML
    Quote: There are no stupid questions, just stupid people.

  3. #3

    Thread Starter
    Hyperactive Member Gimpster's Avatar
    Join Date
    Oct 1999
    Location
    Redmond, WA 98052
    Posts
    331

    Post

    No, I don't want to make a function for it, because I only need it in one place. Thanks anyway. But one other question:

    How can I check to see if a form is loaded? Because if I try to unload a form that is not loaded, then it will give me an error.

    ------------------
    Ryan

  4. #4
    Fanatic Member
    Join Date
    Oct 1999
    Location
    MA, USA
    Posts
    523

    Post

    I don't know if it helps, but if you know the name of this form then you could use this:
    Code:
    Public Function FormLoadedByName(FormName As String) As Boolean
        Dim i As Integer, fnamelc As String
        fnamelc = LCase$(FormName)
        FormLoadedByName = False
        For i = 0 To Forms.Count - 1
            If LCase$(Forms(i).Name) = fnamelc Then
                FormLoadedByName = True
                Exit Function
            End If
        Next
    End Function
    Well it's not perfect but maybe you will be able to use it somehow.
    HTH

    ------------------
    Visual Basic Programmer
    ------------------
    PolComSoft
    You will hear a lot about it.


  5. #5
    New Member
    Join Date
    Feb 2000
    Posts
    8

    Post

    Actually, there is:

    Code:
    For Each Form In Forms
        If Form.Name <> MDIForm.Name Then Unload Form
    Next
    The Forms collection only contains loaded forms. If all your forms (except for the MDIForm) are MDIChildren then this would work. Make sure you make "MDIForm" match the actual name of the form!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width