To loop through all the open forms, you could just use :
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim frm As Form
For Each frm In My.Application.OpenForms
If Not frm.InvokeRequired Then
That's the right idea, but i am looking for the loop to search the entire solution, not just the opened forms. As to what dglienna was saying, is there a forms collection, or do i need to create an array and add each and every one of my forms?
I could do that, but i am looking for an even simpler solution.
To broaden my question, i am actually looking for a way so that a user can save their file and have the current form saved in the text file. Upon load, i want the corresponding form to appear. I have many forms and it would be pointless to have tons of if statements.
I was asking about the for loop because if i could loop through all my forms until the name came up that i was looking for, and made that one visible, i wouldn't have to code for each possible outcome.
So, how can i record the current form to a text file and have it appear upon load???
Here's an idea!
Why not just use the app.config file to store the name of all our forms, then, read it from there ¿
Say for instance you had a form named Form1.
In the Properties Window, select the + sign next to ApplicationSettings
Click on PropertyBinding
You will see a small ellipses button ( ... ) appear inside PropertyBinding
Click on the ellipses button
That will produce a screen called Application Settings for 'Form1'
In the list, scroll down until you find the Name property
Once clicked, you will see a dropdown button, click it
A screen called New Application Setting appears
Give it a name - use the Form's name
Then click OK
And click OK again
Do this for each form
If you were to open your app.config file, you would see a section similar to this :