I haver a user login form (winforms app using vs2005 in VB.NET). After
succesfull validayion of user I want to open a first form and close the
loging form that was used, If I write
If IsValidatedUser(UsernameTextBox.Text, PasswordTextBox.Text) Then
frmCompanySelect.Show()
End If
Me.Close()
This closes the app. If I write
If IsValidatedUser(UsernameTextBox.Text, PasswordTextBox.Text) Then
frmCompanySelect.ShowDialog()
End If
Me.Close()
This opens the form modally but the login form stays in memmory and visible.
How can I open the new form, close the login form (unload it from memory to
get minimum ressource utilisation) and keep the app running?
Any help appreciated,
Bob
You probably have your login form set as your startup form. When you
close the startup form, it closes the entire app. Change it so that
you start from a shared sub main in your main form. Inside sub main,
show your login form with ShowDialog. After it closes, then show the
main form. Something like this:
Shared Sub Main()
'Dim and show the login form
Dim f As New LoginForm
'If the login form returns OK then the user logged in correctly
and
'we can show the main form
If f.ShowDialog = Windows.Forms.DialogResult.OK Then
Application.Run(New Form1)
Else
MsgBox("Invalid Login")
End If
End Sub
You might also experiment with using the built in Splash form in
VB2005. Perhaps you can use the splash form as a login form.
Bob - 21 Dec 2005 19:45 GMT
Thanks for your quick reply,
Bob
> You probably have your login form set as your startup form. When you
> close the startup form, it closes the entire app. Change it so that
[quoted text clipped - 18 lines]
> You might also experiment with using the built in Splash form in
> VB2005. Perhaps you can use the splash form as a login form.
Bob - 21 Dec 2005 19:54 GMT
Your answer also gave me another idea. I looked at the program's properties
dialog box and found I could set the app to close when the last form closes.
Doing that allows me to load the new form and close the login form, the app
then keeps running with the new form open.
This also allows me to call the login form from anywhere within my app after
this and login as another user. That's really going to be helpfull I think.
Thanks Chris
> You probably have your login form set as your startup form. When you
> close the startup form, it closes the entire app. Change it so that
[quoted text clipped - 18 lines]
> You might also experiment with using the built in Splash form in
> VB2005. Perhaps you can use the splash form as a login form.