Results 1 to 6 of 6

Thread: How can you load multiple instances of a form, and interact with each seperately?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2003
    Posts
    1,269

    How can you load multiple instances of a form, and interact with each seperately?

    I want to make a chat application, with rooms and people can message each other. When they do message each other - how can i load up identical forms and be able to interact with them and set variables or send data to each form?

  2. #2
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: How can you load multiple instances of a form, and interact with each seperately?

    VB Code:
    1. Dim Frm as Form1  
    2.     Set Frm = New Form1
    3.     Load Frm
    4.     'Assing values to Properties or Public variables in Frm before show
    5.     'you can send this Form (Parent) as a Property Set
    6.     Frm.Show
    That should be enough, but, if for some reason you want your main Form to get info from these subForms, you can add them to a Public Collection or assign a value to TAG property of each Form and interate trought Forms to get the one you need. Anyway, i don't think you'll need to access each Form from the main Form, since they can report any info to there parent (if you pass the parent as Property Set).

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jul 2003
    Posts
    1,269

    Re: How can you load multiple instances of a form, and interact with each seperately?

    whats a property set o_O

  4. #4
    Frenzied Member
    Join Date
    Aug 2005
    Posts
    1,042

    Re: How can you load multiple instances of a form, and interact with each seperately?

    VaxoP:

    chat application
    people can message each other
    I'm not sure if you want to build a Chat Application or an Instant Messaging Application?
    Either way, there is a little bit more involved than just adding some identical forms.

    This is a very common question that has been asked and answered many time before.

    I would suggest you start by searching the forum.

    Here are a couple of previous posts that might be helpful for you.

    http://www.vbforums.com/showthread.p...highlight=Chat

    http://www.vbforums.com/showthread.p...highlight=Chat

    Good Luck with your applicaation.

  5. #5
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: How can you load multiple instances of a form, and interact with each seperately?

    Property Let: Assign to variable
    Property Get: Get variable/Object
    Property Set: Assign to object

    Wih them you pass or get data to/from Forms, it's better than just using Public variables/Objects inside them. So inside each Chat Form you can have:
    VB Code:
    1. Private FrmParent As Form
    2.  
    3. Public Property Set ParentForm(pForm As Form)
    4.     Set FrmParent = pForm
    5. End Property
    And show each Form with:
    VB Code:
    1. Dim Frm as Form1  
    2.     Set Frm = New Form1
    3.     Load Frm
    4.     'Assing values to Properties or Public variables in Frm before show
    5.     'you can send this Form (Parent) as a Property Set
    6.     Set Frm.ParentForm = Me 'Now Frm knows who is its Parent
    7.     Frm.Show
    Now Frm can use its Parent to Get or Send info
    VB Code:
    1. Me.BackColor = FormParent.BackColor 'Get something
    2. FormParent.Caption = "Hey Im " & Me.Name & " Sending This" 'Send Something
    Last edited by jcis; Jan 29th, 2007 at 07:57 PM.

  6. #6
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: How can you load multiple instances of a form, and interact with each seperately?

    You can store the user's name or ID or whatever is used to identify them in the Tag property of the forms. Then you can iterate through the Forms collection looking for the proper Tag value.

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