473,652 Members | 3,059 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Create form from name

I was using the following code to create a form from its class name. It was
working then at some point I must have broken it, and now have no idea why
it will not work. The CreateInstance method returns <Nothing>

Class MyClass
Function OpenForm(ByVal FormName As String) As Form
Dim obj As Object
obj = Me.GetType.Asse mbly.CreateInst ance(FormName, False)
Return CType(obj,Form)
End Function
End Class

--
Thanks for any help,
Shayne H
Nov 19 '05 #1
3 4448
I've done something just like this just the other day.

I used Activator along with that and used GetExecutingAss embly() instead...

I have the code at work unfortunatly =(
"Shayne H" <shaynehATlycos SPAMGOTOHELLcoD OTuk> wrote in message
news:OO******** ******@tk2msftn gp13.phx.gbl...
I was using the following code to create a form from its class name. It was working then at some point I must have broken it, and now have no idea why
it will not work. The CreateInstance method returns <Nothing>

Class MyClass
Function OpenForm(ByVal FormName As String) As Form
Dim obj As Object
obj = Me.GetType.Asse mbly.CreateInst ance(FormName, False)
Return CType(obj,Form)
End Function
End Class

--
Thanks for any help,
Shayne H

Nov 19 '05 #2
Hello,

"Shayne H" <shaynehATlycos SPAMGOTOHELLcoD OTuk> schrieb:
I was using the following code to create a form from its class name. It was working then at some point I must have broken it, and now have no idea why
it will not work. The CreateInstance method returns <Nothing>


This works for me:

\\\
Dim objNewForm As Object = _
Activator.Creat eInstance( _
Type.GetType("M yApplication.Sa mpleForm") _
)
Dim frm As Form = DirectCast(objN ewForm, Form)
frm.Show()
///

HTH,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet
Nov 19 '05 #3
That was a lot simplier than what I did...
"Herfried K. Wagner [MVP]" <hi*******@m.ac tivevb.de> wrote in message
news:eY******** ******@TK2MSFTN GP10.phx.gbl...
Hello,

"Shayne H" <shaynehATlycos SPAMGOTOHELLcoD OTuk> schrieb:
I was using the following code to create a form from its class name. It

was
working then at some point I must have broken it, and now have no idea why it will not work. The CreateInstance method returns <Nothing>


This works for me:

\\\
Dim objNewForm As Object = _
Activator.Creat eInstance( _
Type.GetType("M yApplication.Sa mpleForm") _
)
Dim frm As Form = DirectCast(objN ewForm, Form)
frm.Show()
///

HTH,
Herfried K. Wagner
--
MVP · VB Classic, VB .NET
http://www.mvps.org/dotnet

Nov 19 '05 #4

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

Similar topics

1
2120
by: dawnunder | last post by:
eg. Someone fills out 3 fields. (There will be more but this is just to give you an idea) 1. Country? 2. State? 3. City I want this script to generate a web page and list the people by
2
4073
by: Nick | last post by:
Loop to create an array from a dynamic form. I'm having trouble with an application, and I'll try to explain it as clearly as possible: 1. I have a form with two fields, say Apples and Oranges. The user selects from a drop down menu, between 1-10 of each and clicks submit. The resulting page will display a NEW form, with rows and a list of fields for the amount of each items selected.
7
3520
by: Bil Muh | last post by:
Esteemede Developers, I would like to Thank All of You in advance for your sincere guidances. I am developing a software using Visual C++ .NET Standard Edition with Windows Form (.NET) template. Briefly -------------------------------------------------------------------------------------------- I need to create dynamically some controls on the forms, and display these
1
1638
by: SAN CAZIANO | last post by:
is there a function that get the name of the first input field of the current form ? in my example below I want create an array of form field name and in the onsubmit assign all element's name to create a simple iteration to test if some elements in my array, that must be required, are null: something like function verify(array of string) and in onsubmit something like return onsubmit(field1,field2,field3....) <HTML> <HEAD>
6
3304
by: SamIAm | last post by:
Hi am creating a email application that needs to mail out a very large amount of emails. I have created a multithreaded c# application that using message queuing. I have created a threadpool of 5 threads and each thread checks the queue, receives the message and sends an email. How do I determine the right amount of threads to create? Thanks, S
4
1751
by: Steven | last post by:
Hi, I have a database table field to store the form name, I want to create the particular windows form by using the value that read from that DB field. For examples, the table field has a value "ThisForm", then I want to create the form with class name "ThisForm" (Suppose I have already defined the class "ThisForm"). Can I do this by using late bindnig? Any source code for reference? Thanks! Steven.
27
3774
by: max | last post by:
Hello, I am a newbye, and I'm trying to write a simple application. I have five tables with three columns; all tables are identical; I need to change some data in the first table and let VB updates the same data in all other four tables in the right places. I know it would be possible by using the ForeignKeyConstraint object. I have created the tables using the DataSet Visual Tool and I know it doesn't create any ForeignKeyConstraint obj....
4
12427
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is this: can Access create the document and place it as an OLE object to the relevant table? Any help is greatly appreciated. Ricky
15
5263
by: lxyone | last post by:
Using a flat file containing table names, fields, values whats the best way of creating html pages? I want control over the html pages ie 1. layout 2. what data to show 3. what controls to show - text boxes, input boxes, buttons, hyperlinks ie the usual. The data is not obtained directly from a database.
7
4936
by: chrismaliszewski | last post by:
Hi. I created code which makes dynamically form with bounded controls for all columns. I show it to you below. My problem is, how I have to change this code to create form which record source are few (e.x. 2) tables? Thank you for help If you want to use this code, you only have to change value of: - nazwaTabeli (table's name of which you want to create form)
0
8811
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8703
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8467
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7302
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6160
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5619
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4145
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
1914
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1591
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.