0

I want to 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?

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

Form1
Button Event
Me.Hide
Form2.Show

Form2
Button Event
Me.Hide
Form1.Show

Edited by yorro: n/a

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.