Computing.Net > Forums > Programming > VB forms

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

VB forms

Reply to Message Icon

Name: eaw8806
Date: January 2, 2004 at 17:24:34 Pacific
OS: win98
CPU/Ram: pentium 2 / 128MB
Comment:

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



Sponsored Link
Ads by Google

Response Number 1
Name: StuartS
Date: January 2, 2004 at 17:38:58 Pacific
Reply:

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



0

Response Number 2
Name: eaw8806
Date: January 2, 2004 at 20:11:08 Pacific
Reply:

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


0

Response Number 3
Name: Burbble
Date: January 2, 2004 at 21:33:49 Pacific
Reply:

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 Integer

Private Sub Command1_Click()
ReDim Preserve NewForms((UBound(NewForms) + 1))
NewForms(UBound(NewForms)).Show
End Sub

Private 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


0

Response Number 4
Name: eaw8806
Date: January 2, 2004 at 21:56:39 Pacific
Reply:

Thank you, Burbble, thats exactly what i was looking for.


0

Response Number 5
Name: Burbble
Date: January 3, 2004 at 07:29:01 Pacific
Reply:

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

-Burbble


0

Related Posts

See More



Response Number 6
Name: eaw8806
Date: January 3, 2004 at 18:50:33 Pacific
Reply:

unless you wanted to use it place of the
Ubound(NewForms)


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: VB forms

Autocad Insert In VB form www.computing.net/answers/programming/autocad-insert-in-vb-form/9161.html

VB.net form parsing with html www.computing.net/answers/programming/vbnet-form-parsing-with-html/12581.html

VB form icon not going away www.computing.net/answers/programming/vb-form-icon-not-going-away/11441.html