0

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?

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by vb5prgrmr
0

What is the purpose of the Class?

Form1 button = fomr1.Hide, Form2.show

Form2 button = Form2.hide, Form1.Show

0

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.