I want tu use more than one form in my project and be able to code a button or something that will do that. I tried this on Form1 and it worked.

Public Class Form1

    Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        'Goes from this form to form 2
        My.Forms.Form2.Show()
    End Sub

End Class

BUT then I tried the following on Form2 to go back to Form1 and it doesn't work... the button does nothing.

Public Class Form2

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        My.Forms.Form1.Show() 'Doesn't work

    End Sub
End Class

Also, when the user switches to a different form, will the variables assigned on the first form still be assigned on the second form (assuming they're declared as Public in the module?

What is the purpose of the Class?

Form1 button = fomr1.Hide, Form2.show

Form2 button = Form2.hide, Form1.Show

OldQ, for future reference you are using .NET code and are presently in the wrong forum. You need to post your Q's in the .NET forum...

In vb6 there are two different ways to accomplish what you want. One is setfocus and the other is zorder.

Good Luck

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.