|
-
Dec 30th, 2005, 05:34 PM
#1
Thread Starter
Member
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?
-
Dec 30th, 2005, 06:12 PM
#2
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:
Module Module1
Public LoginValidated As Boolean = False
Public Sub main()
Application.Run(New Form1)
If LoginValidated = True Then
Application.Run(New Form2)
Else
'run a new form1, display a messagebox, whatever you want
End If
End Sub
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.
-
Dec 30th, 2005, 06:22 PM
#3
Fanatic Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|