How do i open another window and close the active window when i hit a button ?

Beginner

Well-known member
Joined
Mar 12, 2008
Messages
114
Programming Experience
Beginner
As seen in the attached Picture. When i hit the button Calculate i want to open another window and close the active window , How can i do that in an easy way ?
 

Attachments

  • my prog.jpg
    my prog.jpg
    50.6 KB · Views: 32
You would want to hide the main window, not close it.

VB.NET:
dim f2 as form2
me.hide()
f2.show()
me.show()
 
You would want to hide the main window, not close it.

VB.NET:
dim f2 as form2
me.hide()
f2.show()
me.show()

May you please tell me where exactly do i add this ? Im still confused on how to add another form?
How do i do so ?

doneyi5.jpg
 
In Solution Explorer (which is on the right hand side of your IDE), right click on the project "Spur Gear Program", click "add new item" and select Windows Form.

Once you have done that, put that code (changing the names appropriately) into a handler for whatever event you want it triggered by.

Also, you might just want to use ShowDialog instead of Show and forget about hiding/closing the current one - that way the new one will be modal, which means that you won't be able to get back to the current one until it has been closed.
 
You would put that in the button click event of whatever button you want to open the new form.

To add a new form right click on your project in the solution explorer ("Spur Gear Program") and go to Add -> New Item. Select windows form from the new item window and put in an appropriate name. The code I put before would assume the form is called Form2, substitute your form's name for this.
 
Back
Top