PDA

Click to See Complete Forum and Search --> : Proper way to make a login


Kerv20
Oct 25th, 2002, 09:24 AM
I am new to VB.net and have a question about the proper method to startup an application.


I have a user login dialog to load called: frmLogin

If the user submits the correct user name and password I want it to close the login (frmLogin) and open the main MDI form (frmMain).


Here's what I have tried so far without success...

1. Set frmLogin as startup form (displays ok)
2. Validate the password (works properly)
3. Then I do the following

(in the cmdSubmit_click event of frmLogin)

dim frmMain as new frmMain()
frmMain.show() (displays main MDI ok)

me.close() (does not unload the login, but the whole app)


Can anyone give me some pointers as to the correct method to setup a Login dialog which upon user validation calls a main MDI form and unloads the original login dialog ?


Thanks for any help...

:confused:

Edneeis
Oct 25th, 2002, 10:29 AM
Don't have the login form as the startup form. You can show it from within the main form or Sub Main. If you use frmLogin.ShowDialog() then it will show modally if that helps.

m1k3l
Oct 25th, 2002, 11:17 AM
There is no proper way. It's just a matter of style.

I personally like using the login as the startup form and have it pass itself as a reference to the MDI form (or other form that is suppose to be loaded after you log in) and then just hide itself (after resetting the username and password values first of course).

Goes something like this :


'if username and password matches

mdiMain.SetLoginForm(me)
'my own sub that accepts a reference of the frmLogin type

me.hide


So whenever my mdiMain have to go back to the login form i just do this.


_login.Show '_login holds the reference passed in by SetLoginForm

me.dispose 'close the mdiMain