|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
To create an instance of class in VB2005I need to create with VB2005 an instance of one of the classes of the project in run time. For example: - The Namespace root and the name of the project are he himself: "Project" - The project has including three class: Class_1.vb, Class_2.vb and Class_3.vb In VB2003 it did of the following way: Dim NameClass as string ="Class_1" Dim Ensam as Type = Type.GetType("Project" & Chr(46) & NameClass) Dim result as Object = Activator.CreateInstance(Ensam) As it would have to do it in VB2005? if I execute the Type Ensam is Nothing Thanks! Jordi Jordi Julià wrote:
Show quoteHide quote > Hello, The above works for me - are you sure your classes haven't got > > I need to create with VB2005 an instance of one of the classes of the > project in run time. > > For example: > > - The Namespace root and the name of the project are he himself: "Project" > - The project has including three class: Class_1.vb, Class_2.vb and > Class_3.vb > > In VB2003 it did of the following way: > > Dim NameClass as string ="Class_1" > Dim Ensam as Type = Type.GetType("Project" & Chr(46) & NameClass) > Dim result as Object = Activator.CreateInstance(Ensam) > > > As it would have to do it in VB2005? > if I execute the Type Ensam is Nothing themselves nested inside some other class? Try creating an instance of one directly and see what Type it thinks it is: Dim c2 as New Class_2 Debug.Writeline( c2.GetType().ToString() ) HTH, Phill W. Hello,
I have proven what you have said to me and: Dim c2 As New Class_2 '(Class_2 exist in Project) dim Name as string = c2.GetType().ToString 'Name="Project.c2" Dim ensam As Type = Type.GetType(Name) 'ensam = Nothing Because 'ensam' Nothing has left? Thanks! Show quoteHide quote "Phill W." <p-.-a-.-w-a-r-d@o-p-e-n-.-a-c-.-u-k> escribió en el mensaje news:eicrc3$5jh$1@south.jnrs.ja.net... > Jordi Julià wrote: >> Hello, >> >> I need to create with VB2005 an instance of one of the classes of the >> project in run time. >> >> For example: >> >> - The Namespace root and the name of the project are he himself: >> "Project" >> - The project has including three class: Class_1.vb, Class_2.vb and >> Class_3.vb >> >> In VB2003 it did of the following way: >> >> Dim NameClass as string ="Class_1" >> Dim Ensam as Type = Type.GetType("Project" & Chr(46) & NameClass) >> Dim result as Object = Activator.CreateInstance(Ensam) >> >> >> As it would have to do it in VB2005? >> if I execute the Type Ensam is Nothing > > The above works for me - are you sure your classes haven't got themselves > nested inside some other class? > > Try creating an instance of one directly and see what Type it thinks it > is: > > Dim c2 as New Class_2 > > Debug.Writeline( c2.GetType().ToString() ) > > HTH, > Phill W.
Why does activex control run 3x+ faster in vb5 than .net?
Format string in DataGrid TCP Transfer issues Multiple TcpListeners on the same IP address Replacing Double quotes with TWO Single Quotes From VB Newbie: The editor is driving me nuts. Windows Service not starting automatically ATTN: Seth Rowe follow up to startup path posting Import BLOB from XML How do u copy multiple files from a lsbox to somewhere else using vb.net |
|||||||||||||||||||||||