rooney18
01-19-2004, 01:07 PM
please help me.
i am a total beginner to vb .net and want to know if it is possible to close the current form and open another by clicking a button. If it is, how?
any help appreciated.
hope that makes sense. if not please tell me.
cheers
SpiN9823
01-19-2004, 05:04 PM
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim frm As New Form2
frm.Show()
End Sub
Machaira
01-20-2004, 06:30 AM
Add:
Me.Close()
after showing the form
rooney18
01-20-2004, 08:30 AM
thanks, but with the extra code it closes all the forms, not just the previous one. Am i doing something wrong?
reboot
01-20-2004, 10:44 AM
And do you have an Application.Run() ?
SpiN9823
01-20-2004, 06:21 PM
it has to be like this
Private Sub _Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles .Click
Dim frm As New Form2
frm.Show()
Me.Visible = False
End Sub
SpiN9823
01-20-2004, 06:28 PM
did that work?? it worked for me
3dkingpin
02-16-2008, 05:22 PM
all that does is show the new form and 'hides' the current form. The current form will still be there taking up memory etc...
But what you no longer need the form and want to close it (after youve opened the new form)
for example youve just logged in so the login form must close after opening the main form!!!
Machaira
02-16-2008, 06:22 PM
See this thread - http://www.xtremevbtalk.com/showthread.php?t=293332
Shagrath
02-17-2008, 02:18 PM
Me.close() closes all forms because you've written it in the 'base' form.
Try changing the 'base' form of your project.