Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Iterate through all forms in a project... 1

Status
Not open for further replies.

bmgmzp

Programmer
Aug 18, 2006
84
US
I can't seem to find out how to iterate through all the forms in a VB project. Why does this seem so difficult to do? I'm aware of the OpenForms property but I cant really open ALL the forms in my project just to iterate through them.

I can even find out how to reference a form if i have the name:
dim frm as form = Forms("Form1")

Anybody got any advice?
 
I don't really understand the problem.

You have opened a form, but don't really know how to call it?



Christiaan Baes
Belgium

"My old site" - Me
 
I would like to be able to do this:

For each frm as form in MyProject.Forms
messagebox.show(frm.text)
Next frm
 
only for the open forms?

I have soemthing that will do all the forms in the solution open od closed, so actually the classes that inherit from form.

Christiaan Baes
Belgium

"My old site" - Me
 
this works for the open forms.

Private Sub ButtonX1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonX1.Click
Dim frm1 As New Form2
Dim frm2 As New Form3
frm1.Show()
frm2.Show()
For Each f As Form In Application.OpenForms
Me.TextBox1.Text &= f.Text
Next
End Sub

the other solution will be for tomorowmorning in 12 hours or try the search, I'm sure it is in here somewhere.

Christiaan Baes
Belgium

"My old site" - Me
 
Thanks. I'll wait patiently for the code. :)
 
Axtually I think this will help

faq796-6037

you can thank sbendbuckeye, and me of course.

Christiaan Baes
Belgium

"My old site" - Me
 
Thanks chrissie1. I FINALLY was able to iterate through all the forms... WHY IS THAT SO DIFFICULT? ;-) Everything is an object you would think there would be a collection somewhere that would allow for an easy for each loop. WHEW!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top