|
-
Jan 29th, 2007, 07:08 PM
#1
Thread Starter
Frenzied Member
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?
-
Jan 29th, 2007, 07:27 PM
#2
Re: How can you load multiple instances of a form, and interact with each seperately?
VB Code:
Dim Frm as Form1
Set Frm = New Form1
Load Frm
'Assing values to Properties or Public variables in Frm before show
'you can send this Form (Parent) as a Property Set
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).
-
Jan 29th, 2007, 07:44 PM
#3
Thread Starter
Frenzied Member
Re: How can you load multiple instances of a form, and interact with each seperately?
-
Jan 29th, 2007, 07:50 PM
#4
Frenzied Member
Re: How can you load multiple instances of a form, and interact with each seperately?
VaxoP:
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.
-
Jan 29th, 2007, 07:52 PM
#5
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:
Private FrmParent As Form
Public Property Set ParentForm(pForm As Form)
Set FrmParent = pForm
End Property
And show each Form with:
VB Code:
Dim Frm as Form1
Set Frm = New Form1
Load Frm
'Assing values to Properties or Public variables in Frm before show
'you can send this Form (Parent) as a Property Set
Set Frm.ParentForm = Me 'Now Frm knows who is its Parent
Frm.Show
Now Frm can use its Parent to Get or Send info
VB Code:
Me.BackColor = FormParent.BackColor 'Get something
FormParent.Caption = "Hey Im " & Me.Name & " Sending This" 'Send Something
Last edited by jcis; Jan 29th, 2007 at 07:57 PM.
-
Jan 29th, 2007, 09:02 PM
#6
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|