473,396 Members | 1,758 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.

forms collection?

VB2005

Hi!

I know there is an OpenForms collection, but is there also a collection of
all forms defined in an app?
I have built a "shortcut" bar and now need to translate a string variable
"Form1" to an object name Form1.

I thought I'd simply loop through a collection until the string value equals
the form.name. But I cannot find an applicable collection....

Ideas anyone?

Tia,
Martin
Jan 24 '06 #1
5 2176
Martin,

Seen as disproportion by probably all longer using VBNet developpers in this
newsgroup, a part from the My namespace.

As I have read yesterday so nice described by Herfried in another message,
as "faking VB6 behaviour in VBNet".

http://msdn2.microsoft.com/en-us/library/87y2hdsf.aspx

I hope this helps,

Cor
Jan 24 '06 #2
Hi Cor,

Thanks for your response. I have been looking at the My.Forms object, but I
didn't see how I could use it, since it doesn't seem to have an enumerator.

I have the form name in a string variable and I thought to make a function
something like this:

Private Function OpenForm(ByVal FormName as String) as Boolean
For Cntr=0 to My.Forms.Count - 1
If My.Forms(Cntr).Name = FormName then
My.Forms(Cntr).Show()
Exit Function
End If
End Function

In other words, I need to convert a form name in a string to an object....

Tia,
Martin



"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:eb**************@tk2msftngp13.phx.gbl...
Martin,

Seen as disproportion by probably all longer using VBNet developpers in
this newsgroup, a part from the My namespace.

As I have read yesterday so nice described by Herfried in another message,
as "faking VB6 behaviour in VBNet".

http://msdn2.microsoft.com/en-us/library/87y2hdsf.aspx

I hope this helps,

Cor

Jan 24 '06 #3
"Martin" <x@y.com> schrieb:
I know there is an OpenForms collection, but is there also a collection of
all forms defined in an app?
I have built a "shortcut" bar and now need to translate a string variable
"Form1" to an object name Form1.


You may want to use 'Activator.CreateInstance' to instantiate the forms.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jan 24 '06 #4
Hi Herfried,

Thanks for your reply. This sounds like the function I need, but I can't get
it to work...

Dim FormName as string = "frmPatient"
Activator.CreateInstance(FormName, System.Windows.Forms.Form)

This is one of the many things I tried... Unfortunately the Help file is not
very "Helpful"...

What am I doing wrong?

Tia,
Martin
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:uv**************@TK2MSFTNGP09.phx.gbl...
"Martin" <x@y.com> schrieb:
I know there is an OpenForms collection, but is there also a collection
of all forms defined in an app?
I have built a "shortcut" bar and now need to translate a string variable
"Form1" to an object name Form1.


You may want to use 'Activator.CreateInstance' to instantiate the forms.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jan 25 '06 #5
Hi Herfried,

I got it! No thanks to VS2005 help system, but your very informative website
dotnet.mvps.org

This is the code that made it work (maybe someone else would be interested
as well):

Private Sub ShowFormByName(ByVal FormName As String)
Dim frm As Form
Dim tpe As Type
tpe = Type.GetType("appEspital." & FormName)
frm = DirectCast(Activator.CreateInstance(tpe), Form)

frm.MdiParent = Me
frm.Show()

End Sub

Thanks again,
Martin

"Martin" <x@y.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Hi Herfried,

Thanks for your reply. This sounds like the function I need, but I can't
get it to work...

Dim FormName as string = "frmPatient"
Activator.CreateInstance(FormName, System.Windows.Forms.Form)

This is one of the many things I tried... Unfortunately the Help file is
not very "Helpful"...

What am I doing wrong?

Tia,
Martin
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:uv**************@TK2MSFTNGP09.phx.gbl...
"Martin" <x@y.com> schrieb:
I know there is an OpenForms collection, but is there also a collection
of all forms defined in an app?
I have built a "shortcut" bar and now need to translate a string
variable "Form1" to an object name Form1.


You may want to use 'Activator.CreateInstance' to instantiate the forms.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>


Jan 25 '06 #6

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

Similar topics

2
by: Mark Hannon | last post by:
I am designing a PayPal shopping cart/store for a client and have placed several of PayPal's shopping cart forms on the page to correspond with different products. Each form has a unique name...
4
by: Soryt | last post by:
Hi everyone ! 1) An example from help: "Each Form object has a Controls collection, which contains all controls on the form. You can refer to a control on a form either by implicitly or...
4
by: sparks | last post by:
OK we have it so we can use tables to define skip patterns on our forms. BUT we can only do one form. Public Function skipPattern(currentFrm As Form, Optional currentCtl As Control = Null) As...
6
by: Edwinah63 | last post by:
Hi everyone, could someone give me some thoughts on the best way to manage mdi parent and child forms? in vb6 i could scroll through the forms collection and determine which forms were...
5
by: Simon Verona | last post by:
I have an application with a menu system which creates a new thread when a menu item is selected - some of these other threads may open a form for user interaction. Before the menu system is...
15
by: Alex | last post by:
Does anybody know why VB.NET would omit the Forms collection available in previous versions versions of VB? I imagine that there must be a reason why they decided to do away with it, but I can't...
12
by: Peter Van Wilrijk | last post by:
Hi, In VB6 I have the following code ... Dim frmLink As Form Set frmLink = Forms.Add(stringformname) frmLink.Show 'wait until all data has been loaded Do Until frmLink.Loaded = 21 DoEvent
2
by: Yuk Tang | last post by:
I have created my own custom forms called baseform, inheriting normal form properties and such. Baseform is, as can be expected, the basis for the other forms in my project. I want to close all...
18
by: Jerry Boone | last post by:
I'm looking for a way to fire a public sub/function when a form is opened and closed - without using form level events. I have already done some extensive form work with instancing, looping...
21
by: MLH | last post by:
Am having trouble with the following snippet. It stops after only cycling thru open forms. There are many more than that. How to modify this to cycle thru all forms? Sub AllOpenForms() Dim...
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: 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?
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
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
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
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
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.