'檢測子窗體是否打開,沒有的話就打開,打開的放到最前面
If My.Application.OpenForms.Item(MDIFormName) IsNot Nothing Then
' MessageBox.Show("已經打開")
Dim i As Integer '定義變量
For i = 0 To (Me.MdiChildren.Length) - 1 '遍歷子Form
Dim tempChild As Form = CType(Me.MdiChildren(i), Form)
If tempChild.Name = MDIFormName Then '檢測到名字是MDIFormName的form
tempChild.Activate() '顯示子Form
Return '檢測到就退出
End If
Next
Else
Dim frm As Form = MDIForm '子Form名稱
frm.MdiParent = Me
frm.Show()
End If
End Sub