Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / November 2006

Tip: Looking for answers? Try searching our database.

To create an instance of class in VB2005

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jordi Julià - 31 Oct 2006 15:31 GMT
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

Thanks!
Jordi
Phill W. - 02 Nov 2006 14:21 GMT
> Hello,
>
[quoted text clipped - 15 lines]
> 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.
Jordi Julià - 03 Nov 2006 15:31 GMT
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!

>> Hello,
>>
[quoted text clipped - 29 lines]
> HTH,
>    Phill  W.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.