|
方法一(Reflection):
Dim str As String str = "myTest.Form2" '必须是 命名空间+点+窗体类名 Dim tempAssembly As System.Reflection.Assembly = System.Reflection.Assembly.GetExecutingAssembly() Dim frm2 As Form = CType(tempAssembly.CreateInstance(str), Form) frm2.Show()
方法二(Type.GetType() ):
Dim frmName, fullName As String frmName = "form2" fullName = Application.ProductName & "." & frmName Dim frm2 As Form frm2 = Activator.CreateInstance(Type.GetType(fullName, True, True)) frm2 .Visible = True
|