473,406 Members | 2,356 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,406 software developers and data experts.

dynamically create class instance from class name

'Method 1
Dim Form1 As Form = Activator.CreateInstance(Of frmContractEdit)()
Form1.Show()

'Method 2
Dim Form2Type As Type = GetType(frmContractEdit)
MsgBox(Form2Type.AssemblyQualifiedName)
Dim Form2 As Form = CType(Activator.CreateInstance(Form2Type), Form)
Form2.Show()

'Method 3
'Fusion. needs to be in front and was found using MsgBox above
'frmContractEdit needs to have Inherits System.Windows.Forms.Form in its Class definition (designer)
Dim Form3Type As Type = Type.GetType("Fusion.frmContractEdit", True, True)
MsgBox(Form3Type.AssemblyQualifiedName)
Dim Form3 As Form = CType(Activator.CreateInstance(Form3Type), Form)
Form3.Show()

'Method 4
Dim Form4 As Form = CType(Activator.CreateInstance(Type.GetType("Fusio n.frmContractEdit", True, True)), Form)
Form4.Show()
Oct 7 '08 #1
1 4818
'Method 5
'Needs Fusion. in front
'Pass parameters using overload Activator.CreateInstance Object Paramater Array
'frmLegalServicesEdit(ByVal DD_TablesID As String, ByVal dgdBrow As DataGridView)
Dim FType As Type = Type.GetType ("Fusion.frmLegalServicesEdit", True, True)
Dim Args() As Object = {Me.DD_TablesID, Me.dgdBrow}
Dim Form5 As Form = CType(Activator.CreateInstance(FType, Args), Form)
Form5.Show()
Oct 7 '08 #2

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...
11
by: Steven D'Aprano | last post by:
Suppose I create a class with some methods: py> class C: .... def spam(self, x): .... print "spam " * x .... def ham(self, x): .... print "ham * %s" % x .......
2
by: blue | last post by:
I have a class called "MyClass". At runtime, I don't know that the class is of type MyClass but I do know the string name of the class. Is there a way to create an instance of a class when I only...
4
by: Ray | last post by:
I want to dynamically load DLLs (created from VB) and instantiate a class with a particular name, like "ProcessClass". I am able to load the DLL and confirm there is a class by that name BUT I...
9
by: Patrick.O.Ige | last post by:
I have a code below and its a PIE & BAR CHART. The values now are all static but I want to be able to pull the values from a database. Can you guys give me some ideas to do this? Thanks ...
3
by: Tom | last post by:
Hi All : I'm VB.Net Beginner I try to create object Dynamically : In my testing, I create 2 .net project One is MyApp (Type is windows application) with one button name "Button1" The another...
7
by: pmclinn | last post by:
I was wondering if it is possible to dynamically create a structure. Something like this: public sub main sql = "Select Col1, Col2 from Table a" dim al as new arraylist al =...
9
by: sashang | last post by:
Hi I'd like to use metaclasses to dynamically generate a class based on a parameter to the objects init function. For example: class MetaThing(type): def __init__(cls, name, bases, dict,...
5
by: Doug | last post by:
I am looking at using the decorator pattern to create a rudimentary stored proc generator but am unsure about something. For each class that identifies a part of the stored proc, what if I want to...
5
by: akonsu | last post by:
hello, i need to add properties to instances dynamically during run time. this is because their names are determined by the database contents. so far i found a way to add methods on demand: ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.