Results 1 to 12 of 12

Thread: [Resolved] How to get all Form name in my project?

  1. #1

    Thread Starter
    Hyperactive Member solar115's Avatar
    Join Date
    Apr 2002
    Location
    Thailand
    Posts
    268

    [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^

  2. #2
    Fanatic Member laserman's Avatar
    Join Date
    Jan 2002
    Location
    Wales U.K
    Posts
    775
    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

  3. #3

    Thread Starter
    Hyperactive Member solar115's Avatar
    Join Date
    Apr 2002
    Location
    Thailand
    Posts
    268
    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.
    ^solaris^

  4. #4

    Thread Starter
    Hyperactive Member solar115's Avatar
    Join Date
    Apr 2002
    Location
    Thailand
    Posts
    268
    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?
    ^solaris^

  5. #5
    G&G Moderator chemicalNova's Avatar
    Join Date
    Jun 2002
    Location
    Victoria, Australia
    Posts
    4,246
    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:
    1. Public Forms() As Form
    2.  
    3. Public num_forms As Integer
    4.  
    5. Function UpdateList(lst As ListBox, frmName As Form)
    6. lst.AddItem frmName.Name
    7. num_forms = num_forms + 1
    8. End Function

    In the main form...
    VB Code:
    1. Private Sub Form_Load()
    2. num_forms = 0
    3. End Sub


    In all forms created..
    VB Code:
    1. Private Sub Form_Load()
    2. 'add the new form
    3. ReDim Preserve Forms(num_forms)
    4. Forms(num_forms).Name = Me.Name
    5. UpdateList fMain.ListBox, Forms(num_forms)
    6. End Sub


    Does that help?


    Phreak

    Visual Studio 6, Visual Studio.NET 2005, MASM

  6. #6

    Thread Starter
    Hyperactive Member solar115's Avatar
    Join Date
    Apr 2002
    Location
    Thailand
    Posts
    268
    ???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.
    ^solaris^

  7. #7
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974
    if you want to know what forms are currently loaded/visible you can use the forms collection, eg:
    VB Code:
    1. For Each F in Forms
    2.   Msgbox F.Name
    3. 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.

  8. #8

    Thread Starter
    Hyperactive Member solar115's Avatar
    Join Date
    Apr 2002
    Location
    Thailand
    Posts
    268
    si_the_geek,

    Ummm, On forms that I load will be show in list. how can I list all include unloaded form.
    ^solaris^

  9. #9
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974
    Read the second half of my post.

    If you cant work out the code, there are previous examples on this forum.

  10. #10

    Thread Starter
    Hyperactive Member solar115's Avatar
    Join Date
    Apr 2002
    Location
    Thailand
    Posts
    268
    I'm not clear what you mean.
    ^solaris^

  11. #11
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051
    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.


  12. #12

    Thread Starter
    Hyperactive Member solar115's Avatar
    Join Date
    Apr 2002
    Location
    Thailand
    Posts
    268
    Thank you very much laserman, ???phReAk???, si_the_geek, SLH.

    Now I think I got some idea.
    ^solaris^

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width