Site Search:
Sign in | Join | Help
4Penny.net

VB.NET

Notes, Tricks and Tips on VB.NET

How to keep an MDI form from opening twice

The following code will keep a form from opening twice in an MDI environment:

Sub openform(ByVal frm As Form)

Dim f As Form
For Each f In Me
.MdiChildren

If f.Name = frm.Name Then
    Exit
Sub
End If

Next

frm.MdiParent = Me
frm.Show()

End Sub

Comments

 

may said:

what is f in this context?

August 24, 2007 4:41 AM
 

Steve Gray said:

You pass in the form that you want to open (frm), f is a generic form object. We loop through all the forms in the 'mdiChildren' collection and see if this frm is open. 'F' represents the forms in the 'mdichildren' collection.

August 24, 2007 7:38 AM

Leave a Comment

(required)  
(optional)
(required)  
Add

About Steve Gray

Steve is a seasoned (translate: old) developer in VB and ASP.NET. He spends most of his time in Dynamics GP, writing custom mods for consulting firms. Crystal reports, eConnect, VS Tools for Dynamics... anything that comes along.