I want to show Name of all Form that I create in my project that develop by VB.
I know that I can list it by my self but I want to make program to list it automatically.
So, How to get all Form name in my project?
Printable View
I want to show Name of all Form that I create in my project that develop by VB.
I know that I can list it by my self but I want to make program to list it automatically.
So, How to get all Form name in my project?
If you know how too get the Form name then why not try and load them to a textfile just for an example in the form load event of whatever you want.
You could load them from the unload event what do you think?
or even a timer
Just a quick thought
I want to make it list automatically because I want to make sure that all old Form and new Form is load correctly.
If I list it manualy it may be possible to miss or incorrect information in some Form.
More Information:
This Example maybe explain that what is my idea?
- I have 3 Form name fMain, fData, fDetail. So when I run my program I want it to show this 3 names as a list.
- If I create new Form in my program as fAbout I want my program to show all 4 names as a list.
In my meaning about I can list the name by myself is mean I can type name of all Form in my program for show as list. But in fact I want my program to run and check itself that How many form in project? and What's its name?
You could try putting each form into an array, although this may seem like alot more than you are asking:
In a module...
VB Code:
Public Forms() As Form Public num_forms As Integer Function UpdateList(lst As ListBox, frmName As Form) lst.AddItem frmName.Name num_forms = num_forms + 1 End Function
In the main form...
VB Code:
Private Sub Form_Load() num_forms = 0 End Sub
In all forms created..
VB Code:
Private Sub Form_Load() 'add the new form ReDim Preserve Forms(num_forms) Forms(num_forms).Name = Me.Name UpdateList fMain.ListBox, Forms(num_forms) End Sub
Does that help?
Phreak
???phReAk???,
Thak you. But I think...
In your code, for some forms that not load maybe not show in list.
But I want my program to show all list of form name at first time running.
if you want to know what forms are currently loaded/visible you can use the forms collection, eg:
VB Code:
For Each F in Forms Msgbox F.Name Next F
if you want to know the names of all forms (loaded or not), then there is no direct way to do it. The most automated way I have heard is to have your program read the project file (the .VBP), as it has a list of all the forms in the project.
si_the_geek,
Ummm, On forms that I load will be show in list. how can I list all include unloaded form.
Read the second half of my post.
If you cant work out the code, there are previous examples on this forum.
I'm not clear what you mean.
He meens that you cannot really do it at runtime without the help of an external file (or hard-coding the form names). You'd have to load your project file at runtime - which has a list of form names.
Thank you very much laserman, ???phReAk???, si_the_geek, SLH.
Now I think I got some idea.