Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to open a new form but closing the old one in VB

I have a welcome to my application as it loads up, but then need to have that form close and login form open when the continue button is hit.

My code:

    Me.Close()
    Dim Login As New Form
    Login.Show()

When I click the button it only closes the welcome form and then ends the application. If you can help thanks! :)

like image 542
BaeFell Avatar asked Aug 28 '13 14:08

BaeFell


People also ask

How do I close a form and open another form in VB net?

Using our example, we will wire up the button on the subForm to close the form. Click on the tab for the second form (the subForm) in your design and double click on the button control to display the Click event procedure. Press F5 to build and run the application.

How do I close a previous form in VB net?

If you want to close the form then use Me. Close() instead. The Load event will fire again when you create the new instance.

How do I open a new form in Visual Basic?

Add a new formRight-click on the project and choose Add > Form (Windows Forms). In the Name box, type a name for your form, such as MyNewForm. Visual Studio will provide a default and unique name that you may use.


2 Answers

You can set the properties of the project to select "When last form closes" in the shutdown mode dropdown

Update:-

"Project" menu -> 'YourApp' Properties... -> Application Tab

find : "Shutdown Mode"

Change from

"When startup form closes" --> "When last form closes"

like image 185
Rahul Tripathi Avatar answered Sep 30 '22 14:09

Rahul Tripathi


show the form before the close.

Dim Login As New Form
Login.Show()
Me.Close()
like image 42
Markjw2 Avatar answered Sep 30 '22 15:09

Markjw2