[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Multiple instances of the same form

Posted on 2004-11-08
2
Medium Priority
?
213 Views
Last Modified: 2010-04-23
I have a windows form that does lots of stuff. :)  It takes a connection string for its database.  I'd like to have multiples of these forms open.  Like multiple open clients, one per window.  I would need to somehow identify each window or instance.  How would I do that?  I thought this might work:

' Form1
Public Class Form1
    Inherits System.Windows.Forms.Form
    Dim Forms(2) As System.Windows.Forms.Form ' A forms array

    ' Create 2 forms
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Forms(0) = New Form2
        Forms(0).Show()
        Forms(1) = New Form2
        Forms(1).Show()

        'Forms(0).Testvalue = "Form 0" ' Doesn't work
        'Forms(1).Testvalue = "Form 1"
    End Sub
End Class

' Form2
Public Class Form2
    Inherits System.Windows.Forms.Form
    Public TestValue As String
End Class

...but "Forms(0).Testvalue" is invalid.  I don't get why, it's a public variable.  So I put a textbox on form2.  "Textbox1" isn't a property of a "New Form2".

What's the best method of doing this?
Thanks!
0
Comment
Question by:MIKEV
2 Comments
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 1000 total points
ID: 12526915
Change

    Dim Forms(2) As System.Windows.Forms.Form

to

    Dim Forms(2) As Form2

~IM
0
 

Author Comment

by:MIKEV
ID: 12526953
Very cool, immense thanks. :)
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses
Course of the Month19 days, 16 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question