|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
VBN2002 - Programmatically creating a form using a string value as nameI am using VB NET 2002. How can I programmatically create a new windows
form using the value of a string variable as the name of the new form? Public FrmName As String = "MDIChildFrm1" Public %FrmName% as new Form Does not work. I cannot find any information on this anywhere. Please help! Thank You. "Michael Creager" <mdcrea***@adelphia.net> schrieb: You cannot change a variable's name at runtime.>I am using VB NET 2002. How can I programmatically create a new windows > form using the value of a string variable as the name of the new form? > > Public FrmName As String = "MDIChildFrm1" > Public %FrmName% as new Form If the type of the form is variable, take a look at the code below: \\\ Imports System.Reflection .. .. .. Dim frm As Form = _ DirectCast( _ Activator.CreateInstance( _ Type.GetType("MyApplication.SampleForm") _ ), _ Form _ ) frm.Show() /// -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/> If you want a new form and name it something then;
dim frm as new Form Form.Name = "nameofyournewform" If you want to load an existing form using it's name, then do what Herfried posted. Show quoteHide quote "Michael Creager" wrote: > I am using VB NET 2002. How can I programmatically create a new windows > form using the value of a string variable as the name of the new form? > > Public FrmName As String = "MDIChildFrm1" > Public %FrmName% as new Form > > Does not work. > I cannot find any information on this anywhere. Please help! Thank You. > > > >
Please do NOT sign the VB.COM petition
What am I doing wrong - Trying to update Option Strict disallows late binding, need to update code Visual Basic App Memory Issue How to create a zoom feature in Vb.Net Passing objects ByVal vs ByRef Invert an Arraylist.Sort() SharpZipLib Parsing a fixed length record into fields Excel In VB.net |
|||||||||||||||||||||||