Results 1 to 5 of 5

Thread: Load multiple instances of a form, how?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Load multiple instances of a form, how?

    I'm making the chat portion of my program and now I'm stuck. I had wanted to load multiple instaces of a form (template) but I can't make the form names unique since it's read-only. My planned end-result is something like yahoo messenger chat windows, it all looks the same.

    Can anyone help me? This is the draft of the form I'll use as a template.
    Attached Files Attached Files
    Last edited by leinad31; Mar 25th, 2003 at 04:06 PM.

  2. #2
    Frenzied Member McGenius's Avatar
    Join Date
    Jan 2003
    Posts
    1,199
    Something like this:
    VB Code:
    1. Dim frm As form
    2.  
    3.     Set frm = New Form1
    4.     frm.Tag = "New_Form_" & some_unique_value
    5.     frm.Show
    McGenius

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629
    OK, I'll use the Tag for the identifier. BTW, I found this:

    VB Code:
    1. Dim myChildForms(1 to 4) As Form1
    2. Set myChildForms(1) = New Form1
    3. Set myChildForms(2) = New Form1
    4. Set myChildForms(3) = New Form1
    5. Set myChildForms(4) = New Form1

    And I'm considering it since its in an array so the search is easier. I'll probably use a dynamic array instead. Question is, since they will all have the same name (Form1.Name), how will I unload an instance? Unload myChildForms(X)? No other code needed?

    Also, when the form is unloaded, will the reference be still in the array? Will I have to do Set myChildForms(X) = Nothing?

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629
    *bump

  5. #5
    Frenzied Member McGenius's Avatar
    Join Date
    Jan 2003
    Posts
    1,199
    I wouldn't want to hurt anybody's feeling but what you found is very much silly (if not stupid) for number of reasons but the main point would probably be this: why bother declaring multiple variables, arrays (let's forget for the moment that you need object) when all you need is just ONE as I showed you. Just copy that snippet to say button click event so every time you click on it - it will create an instance of Form1. THAT IS ALL YOU NEED and I won't respond to this thread any longer as I just don't know how to explain any better.

    Cheers
    McGenius

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