窗体运行时,根据窗体名称,调用不同的窗体
========================
FormName :需要运行时调用的窗体名称,一定是工程中已经包含的。
ParentForm :所属父窗体对象,如果不需要指定父窗体,可以传入new form
ViewMode :窗体显示模式,如果为True则为showdialog方式,否则为show方式
Private Sub ShowFormByName(FormName As String, ParentForm As Form, Optional ViewMode As Boolean = False)
Dim asm As System.Reflection.Assembly = System.Reflection.Assembly.GetExecutingAssembly
Dim frm1 As New Form
Dim [type1] As Type
For Each type1 In asm.GetTypes
If type1.Name.Trim = FormName.Trim Then
frm1 = asm.CreateInstance(type1.FullName)
If ViewMode = False Then
frm1.Show(ParentForm)
Else
frm1.ShowDialog(ParentForm)
End If
End If
Next
End Sub