In VB.NET, you must perform form instantiation before accessing the form, then you can open, such as:
DIM FRM1 AS New Form1
'frm1.mdiparent = me' Defines MDI Subform
frm.show () 'Opens the form
If you have multiple code accesses the same form in the project, you will create different instances. What is the example of repeatedly opening the MDI child form? The following code can help you complete:
DIM FRM1AS New Form1
Checkform (FRM1, "FORM1")
'********************************************************** *****************************
'* Process Name: Checkform
'* Parameter Description: MdichildForm - The form that needs to be detected; MdichildFormName - the name of the detection form
'* Function Description: First detect if there is a MDI child form, if not, create the form of the MDI child form
'* If there is, there is no form instance in the test, and it is activated; if it is created, its form instance is created.
'********************************************************** *****************************
Private Sub Checkform (Byval Mdichildform AS Form, Byval MdichildFormName As String)
IF me.mdichildren.length <1 THEN
'If there is no MDI child form, the form example of this MDI child form is created.
Showform (MdichildForm)
EXIT SUB
Else
DIM X as integer
Dim frmyn as boolean
For x = 0 to (me.mdichildren.length) - 1
DIM Tempchild as form = ctype (Me.mdichildren (x), form)
If TempChild.name = mdichildformname dam
FRMYN = TRUE
'Detecting the MDI child form, set to True and exit the cycle
EXIT for
Else
frmyn = false
END IF
NEXT
IF frMyn = false
'Didn't detect it in the open form
Showform (Tempform)
Else
'Detect it in the open form to activate
DIM MDICHILDFRM AS FORM = CType (Me.mdichildren (x), FORM)
Mdichildfrm .activate ()
END IF
END IF
End Sub
'********************************************************** *
'* Procedure Name: showform
'* Parameter description: MdichildForm - the form of the instance
'* Function Description: Create a form instance
'********************************************************** *
Private Sub ShowForm (Byval Mdichildform as Form)
Dim Mdichildfrm as form = mdichildform
Mdichildfrm.mdiparent = me 'Defines MDI Subform MDICHILDFRM.SHOW ()' Open Form
End Sub