I was wondering if there is a quick and easy way to unload all of my MDI Child forms.
------------------
Ryan
Printable View
I was wondering if there is a quick and easy way to unload all of my MDI Child forms.
------------------
Ryan
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.
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
I don't know if it helps, but if you know the name of this form then you could use this:
Well it's not perfect but maybe you will be able to use it somehow.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
HTH
------------------
Visual Basic Programmer
------------------
PolComSoft
You will hear a lot about it.
Actually, there is:
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!Code:For Each Form In Forms
If Form.Name <> MDIForm.Name Then Unload Form
Next