Hi,

OK, am new to .net and am having some problems I can't seem to work out.

I have a form called frmExchange that has two buttons and a text box on.

what I want to do is type something into the text box and then click one button (btnAdd) which will then add that text to an arraylist and open a new form - ok can do that! here is the code:

Dim FaxNo As String
        FaxNo = frmExchange.txtNewFaxMachine.Text
        Dim frm As New frmFaxMachine(FaxNo, frmExchange)
        frm.Show()
        FaxArray.Add(FaxNo)

This then opens up the form that has the following:

Public Sub New(ByVal Num As String, ByVal ex As frmExchange)
        ' This call is required by the Windows Form Designer.
        InitializeComponent()
        ' Add any initialization after the InitializeComponent() call.
        exch = ex
        myNumber = Num
        Me.Text = myNumber
    End Sub

What I want to be able to do is open as many forms as I want and then be able to reference them individually so I could close one. I want to be able to do this by typing in the instance name in the textbox of the first form and then click the second button (btnRemove) that will run

frm.close()

.

I have no idea how to do it - I was trying to assign the form a name and then try and refernce that - can anyone help??? PLEASE

Cheers

Ben

P.S. This is my first post so be kind ;)

You can try code similar to this:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim newForm(1) As Form

        newForm(0) = New Form2
        newForm(0).Show()

        newForm(1) = New Form2
        newForm(1).Show()

    End Sub

What this code does is create an array of type Form. It then sets the elements in the array to new instances of the form Form2. You can then access the properties of the form through the array.

Would that work with a variable array

newForm() = new form2
newform().Show()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.