MarcGraff
asked on
VB.NET passing control to another form
I am new at .net so bare with me...
I have a login form where the user puts in the user name and password then I want it to open a menu form.
The problem is when I close the login form the application closes. Is there a way to pass off the control?
I am currently useing this:
Dim objForm As New FrmMenu()
objForm.Show()
objForm.Visible = True
But I am up for any suggestion!
Thanks,
- Marc
I have a login form where the user puts in the user name and password then I want it to open a menu form.
The problem is when I close the login form the application closes. Is there a way to pass off the control?
I am currently useing this:
Dim objForm As New FrmMenu()
objForm.Show()
objForm.Visible = True
But I am up for any suggestion!
Thanks,
- Marc
ASKER
then how would the application terminate when the menu form is closed? currently it just sits in memory.
- Marc
- Marc
MarcGraff,
The correct way to do this probably is to set the startup object to Sub Main
You create sub main in a module.
In this module, you call the login form as a dialog box, and once it exits from there, you call the menu form.
You can program the queryunload event of this last form to close the application properly
Dabas
The correct way to do this probably is to set the startup object to Sub Main
You create sub main in a module.
In this module, you call the login form as a dialog box, and once it exits from there, you call the menu form.
You can program the queryunload event of this last form to close the application properly
Dabas
ASKER
queryunload?
- Marc
- Marc
ASKER
Asuming you are refering to Handles MyBase.Closed,
How would I close the Login Form from the Menu Form
or
How do I stop the application from emedietly ending when useing submain
Sub Main()
Dim Login As New FrmLogin()
Login.Show()
End Sub
- Marc
How would I close the Login Form from the Menu Form
or
How do I stop the application from emedietly ending when useing submain
Sub Main()
Dim Login As New FrmLogin()
Login.Show()
End Sub
- Marc
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Dim Login As New FrmLogin()
Dim objForm As New FrmMenu()
Login.ShowDialog() ' works great
objForm.Show() ' FrmMenu shows but closes emedietly and the app ends :(
I tryed: objForm.ShowDialog()
and it works... Should I not do this?
- Marc
Dim objForm As New FrmMenu()
Login.ShowDialog() ' works great
objForm.Show() ' FrmMenu shows but closes emedietly and the app ends :(
I tryed: objForm.ShowDialog()
and it works... Should I not do this?
- Marc
MarcGraff,
It will also work.
You will understand exactly what happens if you single step through the code as I wrote it:
You will see that after Login.ShowDialog, the Login form comes up, but Sub Main waits for you to close it before proceeding with the next line.
After objForm.Show, the menu form will show up, but Sub Main will continue with End Sub, thereby removing itself from memory.
Dabas
It will also work.
You will understand exactly what happens if you single step through the code as I wrote it:
You will see that after Login.ShowDialog, the Login form comes up, but Sub Main waits for you to close it before proceeding with the next line.
After objForm.Show, the menu form will show up, but Sub Main will continue with End Sub, thereby removing itself from memory.
Dabas
ASKER
Thanks so much!
- Marc
- Marc
After objForm.Show I suggest you try:
Me.Hide
Dabas