Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
hey all, i havent been here in a while, i've been working on an encryption algorithm and im hoping to make it into an instant messenger. I have come across the problem of having multiple copies of the same IM window open at once. Do I have to make just a whole bunch of forms that are the same? or is there a way to make just one, and have it opened in different windows? I think it might have something to do with threads, but i dont have much more than a general idea of threads, so im not sure. Sorry if i'm not very clear in my question, any help is appriciated though. thanks
eaw8806

You need to be looking at an Array of Forms. You create a form with an index of 0 as design time. At runtime you can create more forms using the Load statement. Forms can be closed using Unload. Forms are Windows in VB. Each form has its own Window. You cannot have multiple forms in the same Windows but you can have multiple objects on the same form.
Forget about threads in VB. Although it can be done it is far to complicated and there is usually a better way of doing things without resorting to multiple threads.
Stuart

the last time i tried to create multiple windows from the same form using an index, VB didnt let me have an index of forms. i know about objects and such, and i know about the form load and unload stuff, im not new to VB. Basically, im looking for this:
I create a form, Form1. I want it to open multiple times, but in different windows. is this possible? I could just make a whole bunch of forms, like Form1, Form2, Form3 ect, and make them all the same, and load them seperatly, but i was wondering to save space if i could just use one. Is this possible? any help is appriciated, thanks Stuart for answering.eaw8806

Here you go:
This example has two forms in a project - frmMain, with a command button on it, and frmNew, with whatever you want on it.
Put this code into frmMain:
Dim NewForms() As New frmNew
Dim FormCount As IntegerPrivate Sub Command1_Click()
ReDim Preserve NewForms((UBound(NewForms) + 1))
NewForms(UBound(NewForms)).Show
End SubPrivate Sub Form_Load()
ReDim NewForms(0)
End Sub
It's pretty basic, but you can change it around a little to make it suit your needs.-Burbble

Oops, I realize that I declared a variable that was unnecessary (FormCount)... Just ignore that ;)
-Burbble

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |