Loading forms without using variables
Loading forms without using variables
Loading forms without using variables
Loading forms without using variables
Loading forms without using variables
Loading forms without using variables Loading forms without using variables Loading forms without using variables Loading forms without using variables Loading forms without using variables Loading forms without using variables Loading forms without using variables Loading forms without using variables
Loading forms without using variables Loading forms without using variables
Loading forms without using variables
Go Back  Xtreme Visual Basic Talk > > > Loading forms without using variables


Reply
 
Thread Tools Display Modes
  #1  
Old 06-22-2006, 06:00 PM
zekethefreak zekethefreak is offline
Newcomer
 
Join Date: Jun 2006
Posts: 2
Default Loading forms without using variables


I have about 30 variations of a base form in my project.
According to an internal id, i need to use one of those forms.
Right now this is achieved by maintaining (by hand!) a big select case structure.
Since we have about 100 lines in that structure, im now looking for a cleaner way to achieve this.

Is there a way to say:
myForm = loadForm("model4")
myForm.show

And having it work? i have found NO way to 'walk' the unopened forms in a vb project, neither a way to refer to them by strings and not variables.

Any help will be highly appreciated.

Thanks a lot!

Ezequiel.
Reply With Quote
  #2  
Old 06-22-2006, 07:19 PM
cryo_burned cryo_burned is offline
Freshman
 
Join Date: May 2006
Posts: 25
Default

Code:
Dim myForm As New model4 myForm.Show
Reply With Quote
  #3  
Old 06-22-2006, 07:26 PM
cryo_burned cryo_burned is offline
Freshman
 
Join Date: May 2006
Posts: 25
Default

o wait... sorry.. by model4 do you mean model4 is variation4 of Form2 (or other form) or that model4 is the name of a form already?
Reply With Quote
  #4  
Old 06-22-2006, 07:56 PM
b0b b0b is offline
Contributor
 
Join Date: Jul 2003
Posts: 741
Default

Forms is a collection holding all loaded forms in a project. You can use a For Each loop to step through the forms of a project.

Code:
Dim TmpFrm As Form For Each TmpFrm In Forms If TmpFrm.Name = "model4" Then 'identify the form you want then take any neccessary action TmpFrm.Show End If Next TmpFrm
Reply With Quote
  #5  
Old 06-23-2006, 12:50 PM
zekethefreak zekethefreak is offline
Newcomer
 
Join Date: Jun 2006
Posts: 2
Default

Quote:
Originally Posted by b0b
Forms is a collection holding all loaded forms in a project. You can use a For Each loop to step through the forms of a project.

Code:
Dim TmpFrm As Form For Each TmpFrm In Forms If TmpFrm.Name = "model4" Then 'identify the form you want then take any neccessary action TmpFrm.Show End If Next TmpFrm
The problem with that solution is that it requires the form to be loaded. And i'm running on the basis that i have an unknown number of forms, all with different names, and that those forms are not loaded at program startup.

For example, let's say i have 3 forms: formA, formB and formC
FormA is loaded at the start of the program, and formB and formC are not.
If i want to show formB i should use the following line:
formB.show
But, what if i have the form i want to use is stored in a string somewhere? i would need to refer to it by that string, and not by it's variable name:
getForm(formToBeLoaded).show
Now, my question is: is there a way to refer to get the object of a currently existing form without needing it's name to be explicitly present in the form?

Thanks a lot!

By the way, i have no idea why i posted this in the communications forum. Is there a way to move the thread to the general section?
Edit by moderator: you can't, but I took care of it for you.


Eze.

Last edited by wayneph; 06-23-2006 at 01:41 PM.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Loading forms without using variables
Loading forms without using variables
Loading forms without using variables Loading forms without using variables
Loading forms without using variables
Loading forms without using variables
Loading forms without using variables Loading forms without using variables Loading forms without using variables Loading forms without using variables Loading forms without using variables Loading forms without using variables Loading forms without using variables
Loading forms without using variables
Loading forms without using variables
 
Loading forms without using variables
Loading forms without using variables
 
-->