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

Switchboard in VB.net

Hello all.. I'm making a dynamic menu in VB net for an aplication but i'm
having an issue ...

I need to use a varable as part of an argument when opening new forms..

example..

Dim X as string
x= rs.fields("formname")

dim View me as new X

how do I get VB.Net to reconize that x is an aculy form and create a new
instance of it...

Many thanks,

Tom T

--
Message posted via http://www.dotnetmonster.com
Nov 22 '05 #1
2 2223
Tom, If I understand you, you want to pass an argument to a new form when you
create the form. So you want code like:

Dim frm As New Form2(myVariable)

Then in the From2.vb code you need to add a constructor for the variable
provided. Like the following which changes the title of the new form to the
string that is passed to it on the creation. (ByVal is the default.)

Public Sub New(ByVal x)
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call
Me.Text = x
End Sub
"Tom T via DotNetMonster.com" wrote:
Hello all.. I'm making a dynamic menu in VB net for an aplication but i'm
having an issue ...

I need to use a varable as part of an argument when opening new forms..

example..

Dim X as string
x= rs.fields("formname")

dim View me as new X

how do I get VB.Net to reconize that x is an aculy form and create a new
instance of it...

Many thanks,

Tom T

--
Message posted via http://www.dotnetmonster.com

Nov 22 '05 #2
My VB.NET is rusty, so hopefully you can figure out the equivalent code.
This c# code will work:

string x = rs.fields("formname")
// note that formname must be the full name of the class
// including the namespace
Type formType = Type.GetType(x);
System.Reflection.ConstructorInfo constructor =
formType.GetConstructor(new Type[0]);

Form newForm = (Form) constructor.Invoke(new object[0]);
newForm.Show();

The key methods to look at are the static Type.GetType() and instance
method Type.GetConstructor(). They will let you create an instance of
an class, when you only have the name of the class as a string.
Joshua Flanagan
http://flimflan.com/blog

Tom T via DotNetMonster.com wrote:
Hello all.. I'm making a dynamic menu in VB net for an aplication but i'm
having an issue ...

I need to use a varable as part of an argument when opening new forms..

example..

Dim X as string
x= rs.fields("formname")

dim View me as new X

how do I get VB.Net to reconize that x is an aculy form and create a new
instance of it...

Many thanks,

Tom T

Nov 22 '05 #3

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

Similar topics

13
by: Mark | last post by:
I am looking for a switchboard creator alternative for my MDB. Can anyone help me? Thanks for your help, Mark
2
by: Dannic | last post by:
Here is the application. Its a simple application really. I have a db created in Access 2000 which opens to a switchboard created by the switchboard manager. Now the problem. This only works...
2
by: Dejan M. | last post by:
Can you help me? I have 9 forms in the base. 2 forms are opening as single and 7 as datasheet. Thats OK, but when I used Switchboard manager, with him all of my forms are opened as single. How can...
2
by: Terry | last post by:
I have created a switchboard, created using Access 2000. If I put the mouse anywhere on the form, outside of the checkboxes and scroll the wheel backwards, I get the following error. Run-Time...
4
by: Rampar | last post by:
I did some customizing on my switchboard (changing colors and adding graphics) to make it more appealing. I tried to add another item, and it told me that 8 was the limit. Fine. I deleted one...
5
by: Michael Keene | last post by:
I have a query that I'd like to add to my switchboard, but when I use the switchboard manager I only get the option to run a report, a macro or open a form. Is there a way to add a query without...
2
by: Neil Greenough | last post by:
I am trying to create a Switchboard using the Switchboard Manager in MS Access 2000. I have managed to get the table created for the switchboard, however it hasn't actually created the form. ...
1
by: jimwlee | last post by:
Hi all, I mistakenly deleted my switchboard on the Object Forms view. I recreated it again with the database utility, but the switchboard isn't showing up in the forms view. Any ideas? Thanks in...
1
by: mplus_2000 | last post by:
I have recently inherited a database. The switchboard (and other forms) displays the name of the database on it (top, center). Currently the name that appears is Reviews. There are plans to roll...
2
by: Earl Anderson | last post by:
In Acc2003, I have a situation in which I have a main switchboard and upon pressing one of its buttons , takes the user to another sub hierarchical switchboard. Pressing one of these buttons could...
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
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
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.