473,387 Members | 1,575 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,387 software developers and data experts.

variable form type ... can this be done in VB.Net


I would like to do the following ...

Dim lType as String

lType = "frmReport100"

Dim lFrm as lTtype

lFrm.ShowDialog

basically, I want to be able to create a form of type 'StringValue' ... i
want to use a string value to define the type of form to open.

Can I do this, and how would it be accomplished.

Thanks
Jeff

DoI need to loop through all the forms in the application ?
Jun 25 '07 #1
7 1231
Jeff,

VBS and VBA are made for that kind of solutions.

In VB.Net it makes no sence because you can forever make a table with your
existing forms and select that.

Cor

"jeff" <jhersey at allnorth dottt comschreef in bericht
news:eP**************@TK2MSFTNGP06.phx.gbl...
>
I would like to do the following ...

Dim lType as String

lType = "frmReport100"

Dim lFrm as lTtype

lFrm.ShowDialog

basically, I want to be able to create a form of type 'StringValue' ... i
want to use a string value to define the type of form to open.

Can I do this, and how would it be accomplished.

Thanks
Jeff

DoI need to loop through all the forms in the application ?

Jun 25 '07 #2
reflection is your friend...

"jeff" <jhersey at allnorth dottt comwrote in message
news:eP**************@TK2MSFTNGP06.phx.gbl...
>
I would like to do the following ...

Dim lType as String

lType = "frmReport100"

Dim lFrm as lTtype

lFrm.ShowDialog

basically, I want to be able to create a form of type 'StringValue' ... i
want to use a string value to define the type of form to open.

Can I do this, and how would it be accomplished.

Thanks
Jeff

DoI need to loop through all the forms in the application ?

Jun 25 '07 #3
Perhaps this will assist you.
Sub ShowForm(ByVal FormName As String)
Dim ProjectName As String =
Reflection.Assembly.GetExecutingAssembly.GetName.N ame
Try
Dim FormType As Type = Type.GetType(ProjectName & "." & FormName)
Dim frmObject As Object = Activator.CreateInstance(FormType)

DirectCast(frmObject, Form).StartPosition =
FormStartPosition.CenterParent
DirectCast(frmObject, Form).ShowDialog()
Catch ex As Exception
Console.WriteLine("Oooops")
Console.WriteLine(ex.Message)
End Try
End Sub


"jeff" <jhersey at allnorth dottt comwrote in message
news:eP**************@TK2MSFTNGP06.phx.gbl...
>
I would like to do the following ...

Dim lType as String

lType = "frmReport100"

Dim lFrm as lTtype

lFrm.ShowDialog

basically, I want to be able to create a form of type 'StringValue' ... i
want to use a string value to define the type of form to open.

Can I do this, and how would it be accomplished.

Thanks
Jeff

DoI need to loop through all the forms in the application ?

Jun 25 '07 #4
Armin,

I thought you did (like me) not like late binding, the method I provid is so
simple.

Cor

"Armin Zingler" <az*******@freenet.deschreef in bericht
news:Ok**************@TK2MSFTNGP05.phx.gbl...
"jeff" <jhersey at allnorth dottt comschrieb
>>
I would like to do the following ...

Dim lType as String

lType = "frmReport100"

Dim lFrm as lTtype

lFrm.ShowDialog

basically, I want to be able to create a form of type 'StringValue'
... i want to use a string value to define the type of form to open.

Can I do this, and how would it be accomplished.

Thanks
Jeff

DoI need to loop through all the forms in the application ?


The name of a class should not matter at runtime, however, if you need it,
have a look at http://msdn2.microsoft.com/en-us/library/k3a58006.aspx
(look for "CreateInstance" on the page)
Armin

Jun 26 '07 #5
"Cor Ligthert [MVP]" <no************@planet.nlwrote in
news:#7**************@TK2MSFTNGP06.phx.gbl:
I thought you did (like me) not like late binding, the method I provid
is so simple.
Yes definately simple - bit slightly hardcoded. Tho an array of types +
late binding = plugin system :-)
Jun 26 '07 #6
"Cor Ligthert [MVP]" <no************@planet.nlschrieb
Armin,

I thought you did (like me) not like late binding,
Yes, I don't like it as long as it is avoidable and can be done with other
programming means. I also expressed it by writing that a class name should
not matter at runtime. Though, I didn't want to conceal the possibility of
reflection. In the end, it's up to the OP to use it or not.
I didn't see Smokey's answer yet when I was answering, and.....
the method I
provid is so simple.
..... I didn't have your 2nd post where you explained what you mean with
"table".

BTW, Hi Cor (and Hi group)! :-)
Armin

Jun 26 '07 #7
Cor Ligthert [MVP] schreef:
Jeff,

VBS and VBA are made for that kind of solutions.

In VB.Net it makes no sence because you can forever make a table with your
existing forms and select that.

Cor
Cor, even een tip. Ik heb je deze fout al veel zien maken. Jij schrijft
vaak 'forever' wanneer je 'always' bedoeld.
--
Rinze van Huizen
C-Services Holland b.v
Jun 29 '07 #8

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

Similar topics

6
by: BigDadyWeaver | last post by:
I am using the following code in asp to define a unique and unpredictable record ID in Access. <% 'GENERATE UNIQUE ID Function genguid() Dim Guid guid =...
8
by: 2L | last post by:
Trying to write some code and this is just shitting me now! Bit of form validation stuff.... Variable is declared as follows..... --snip-- <script language="JavaScript"> <!---
5
by: tim.pascoe | last post by:
I'm attempting to modify some Crosstab generating code, and I need some advice/examples. Currently, the code uses a single string variable to store the dynamically generated query...
7
by: JS | last post by:
I have a series of pages which make up a questionnaire. It's all done in PHP and I'd like to have two submit buttons (well, images really) so that one submits the form and takes them to the next...
3
by: Shabam | last post by:
I have a form page that accepts a text field variable. The problem is, I need to concatenate this text field variable with some other string. How can I get this done? So, suppose a user enters...
134
by: James A. Donald | last post by:
I am contemplating getting into Python, which is used by engineers I admire - google and Bram Cohen, but was horrified to read "no variable or argument declarations are necessary." Surely that...
8
by: Groups User | last post by:
C allows type casting in which a variable is converted from one type to another. Does C (whatever standard) allow the type of a variable to change, within a statement, avoiding the conversion?...
20
by: MLH | last post by:
120 MyString = "How many copies of each letter do you need?" 150 MyVariant = InputBox(MyString, "How Many?", "3") If MyVariant = "2" Then MsgBox "MyVariant equals the string '2'" If...
3
by: rGenius | last post by:
hi all, im planning to create a lookup usercontrol where i need to specify a custom property (a form) to be loaded up once a button is pressed. usercontrol contains: textbox button now...
11
by: Jef Driesen | last post by:
I have the following problem in a C project (but that also needs to compile with a C++ compiler). I'm using a virtual function table, that looks like this in the header file: typedef struct...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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
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...

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.