Going from one form to another form

SkyNet

Member
Joined
Jan 26, 2009
Messages
5
Programming Experience
Beginner
Hi, I've got a beginner problem :), I've a login form which is opened whit form.show(), which validate the user and password into a database, however, when I click OK button, if every think match ok, it should close this form and open a new one.
However always when I use form.close() it close both forms, the first one that I want to close and the new one that I want to open.
I've putted on
Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
.......
form1.close()
form2.show()
==================================
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
form1.close()

On both routines both forms are closed.

Can someone help me please

Thanks
 
With such setup you have to change application shutdown setting from "when main form closes" to "when last form closes", see Application tab in project properties.

IMO a better setup for a login form is to set the real main form as startup form for application and use the Application Startup event to validate user, then cancel application startup if login fails. Click "view application events" in same app property tab to find Application Startup event, it is a cancelable event that is controlled with e.Cancel.
 
Back
Top