|
-
Mar 22nd, 2004, 03:15 AM
#1
Thread Starter
Hyperactive Member
[Resolved] How to get all Form name in my project?
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?
Last edited by solar115; Mar 22nd, 2004 at 05:36 AM.
^solaris^
-
Mar 22nd, 2004, 03:28 AM
#2
Fanatic Member
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
-
Mar 22nd, 2004, 03:38 AM
#3
Thread Starter
Hyperactive Member
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.
-
Mar 22nd, 2004, 04:56 AM
#4
Thread Starter
Hyperactive Member
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?
-
Mar 22nd, 2004, 05:02 AM
#5
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
Visual Studio 6, Visual Studio.NET 2005, MASM
-
Mar 22nd, 2004, 05:07 AM
#6
Thread Starter
Hyperactive Member
???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.
-
Mar 22nd, 2004, 05:08 AM
#7
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.
-
Mar 22nd, 2004, 05:13 AM
#8
Thread Starter
Hyperactive Member
si_the_geek,
Ummm, On forms that I load will be show in list. how can I list all include unloaded form.
-
Mar 22nd, 2004, 05:19 AM
#9
Read the second half of my post.
If you cant work out the code, there are previous examples on this forum.
-
Mar 22nd, 2004, 05:27 AM
#10
Thread Starter
Hyperactive Member
I'm not clear what you mean.
-
Mar 22nd, 2004, 05:31 AM
#11
Not NoteMe
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.
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe
"I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
Have I helped you? Please Rate my posts. 
-
Mar 22nd, 2004, 05:35 AM
#12
Thread Starter
Hyperactive Member
Thank you very much laserman, ???phReAk???, si_the_geek, SLH.
Now I think I got some idea.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|