-
Switch between froms.
Hi~~
try to switch between different forms in my code, but how do I close my first form once I open the second form?
the following is my code, can anyone tell me where I did wrong?
Private Sub btnForm2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnForm2.Click
Dim frmForm2 As New frmForm2()
Dim frmForm1 As New frmForm1()
frmForm2.Show()
frmForm1.Hide()
End Sub
Thank you for your help .
-
You may want to use the Close function for forms. This seems to work.
-
You can use Load to load a form into memory and Unload to unload it... Show to show a form (if it is not load, it loads), and Hide to hide it (but still in memory unless using unload).
You cannot use the code above, because you are creating a new instance for frmForm1 and frmForm2.
Try just with
Private Sub Command1_Click()
Form2.Show
Form3.Hide
End Sub
Private Sub Command2_Click()
Form3.Show
Form2.Hide
End Sub