Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / December 2005

Tip: Looking for answers? Try searching our database.

Showing form , closing login form but not closing app, how

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bob - 21 Dec 2005 19:18 GMT
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
Chris Dunaway - 21 Dec 2005 19:40 GMT
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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.