473,396 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Create Instance of a Class from ClassName

I want to pass a variable to a Procedure and have that function instantiate
an instance of that class. For example, I have a Class named "myClass":

CreateInstance ("myClass")

Sub CreateInstance (classname as string)
Dim newinstance as classname
.....
End Sub

Is there anyway that I can do this?
--
Dennis in Houston
Nov 21 '05 #1
2 2364
Hi Dennis

Try Activator.CreateInstanceFrom - that should do the trick for you.

HTH

Nigel Armstrong

"Dennis" wrote:
I want to pass a variable to a Procedure and have that function instantiate
an instance of that class. For example, I have a Class named "myClass":

CreateInstance ("myClass")

Sub CreateInstance (classname as string)
Dim newinstance as classname
.....
End Sub

Is there anyway that I can do this?
--
Dennis in Houston

Nov 21 '05 #2
Dennis,

When you do this, than are programlanguages as VBA or JS the best for that.

However VBNet is made to create good working executes in runtime.

Just my thought

Cor
"Dennis" <De****@discussions.microsoft.com>
I want to pass a variable to a Procedure and have that function instantiate
an instance of that class. For example, I have a Class named "myClass":

CreateInstance ("myClass")

Sub CreateInstance (classname as string)
Dim newinstance as classname
.....
End Sub

Is there anyway that I can do this?
--
Dennis in Houston

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Robert Oschler | last post by:
Hello, I am a Python newbie (by experience, not chronologically :) ), so if any of this doesn't make sense my apologies in advance. I am reading the chapter in The Python Cookbook on databases...
9
by: Tian | last post by:
How can I create an instance of an object from a string? For example, I have a class Dog: class Dog: def bark(self): print "Arf!!!" I have a string: classname = "Dog"
20
by: jernej goricki | last post by:
Hi, Is it possible to do this in vb.net : 1.)To make a function that would have a string parameter ClassName 2.)This function would return an object of the same type as the ClassName parameter...
0
by: Greg Conely via .NET 247 | last post by:
I am creating a application that will be using plugins. I am doing this so that when I want to let this application work with another type of dbase system, I only have to write\install one plugin,...
6
by: Rene Mansveld | last post by:
Hi, how can I create an instance (object) of a class (form) if I only know the classname (VB.NET 1.0)? I need to do this in a complex app where jobs consist of parts. Each part's data is saved...
2
by: §iD` | last post by:
Hi! I would like to create a virtual folder (which I want to mount) and populate managing his content by a DLL or something like that in VB.NET (2.0). How can I acomplish this? Thanks to...
8
by: Bert | last post by:
Hi, I want to create an instance of a class by means of the classname. Can't figure out how. in pseudocode this would look like: Dim MyClassName as String = "MyClass" Dim MyObject as New...
9
by: Bo Yang | last post by:
Hi, I know in java , we can use class.ForName("classname") to get an instance of the class 'classname' from a string , in python , how do I do that ? Thanks in advance !
2
by: inetjack | last post by:
Hi, This is a little test application, generating and compiling code at runtime. The loadClassLoader() method of the Factory Object suppose to unload all class previously loaded. It does not...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.