Results 1 to 3 of 3

Thread: Calling forms in sequence

  1. #1

    Thread Starter
    Member
    Join Date
    Dec 2004
    Posts
    54

    Calling forms in sequence

    Hi,
    I'm writing an application which firstly displays a loginform.
    When the user has finished validating himself, I want to open the programform, and close the login form.

    The project is set up to start the loginform upon execution.

    The problem is that the program quits when I do a me.close on the loginform. I do a .show on the programform before I call the loginforms me.close so that I have a form active, but still the entire program quits.

    I'm (trying) to use a MVC (Model-View-Controller) design on my program.

    What am I missing? How could I fix this?

  2. #2
    PowerPoster
    Join Date
    Aug 2005
    Location
    College Station, TX
    Posts
    4,521

    Re: Calling forms in sequence

    I would assume starting up with sub main. Set the startup object to sub main, then add a module with the following code:
    VB Code:
    1. Module Module1
    2.     Public LoginValidated As Boolean = False
    3.     Public Sub main()
    4.         Application.Run(New Form1)
    5.         If LoginValidated = True Then
    6.             Application.Run(New Form2)
    7.         Else
    8.             'run a new form1, display a messagebox, whatever you want
    9.         End If
    10.     End Sub
    11. End Module
    This creates a loginvalidated variable, that you can set to true in form1 if login is successful (LoginValidated = True)... Then when you close the form, if the validated variable is true, it would then run form2 when form1 is closed. If false, you can add a case in the else statement in the module to run a new form1, display a message, or whatever you want. Not sure if this is the best way, but its one way...
    Last edited by gigemboy; Dec 30th, 2005 at 06:21 PM.

  3. #3
    Fanatic Member cpatzer's Avatar
    Join Date
    Sep 2004
    Posts
    537

    Re: Calling forms in sequence

    You could also have the main form's visiblity property set to false. In it's load event show the login form. If the login is good, close the login form from the main form and and set the mainform's visibilty property to true.
    In life you can be sure of only two things... death and taxes. I'll take death.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width