peanut1010
asked on
vb.net closing a form
I have 3 forms 1st is a splash then the login and finally the mdi
in the splash screen it calles
Dim Login As New Login
Login.ShowDialog()
then the login form show and the user logs in. if it is the correct password it should open up the mdi form and show certain buttons depending on who it is
I have this
dim mdi as new mdi
mdi.toolbar1.items.button( 0).visible = true
mdi.show
then I want to close the login form so I put me.close
it ends up closing the whole program.
How do I fix this???
in the splash screen it calles
Dim Login As New Login
Login.ShowDialog()
then the login form show and the user logs in. if it is the correct password it should open up the mdi form and show certain buttons depending on who it is
I have this
dim mdi as new mdi
mdi.toolbar1.items.button(
mdi.show
then I want to close the login form so I put me.close
it ends up closing the whole program.
How do I fix this???
create a new module
in the module create a method "Main"
Public Sub Main
End Sub
Edit project properties so the startup object is Sub Main
Now within Sub main do what ever you need to do with your splash and login forms and when you are finally settled in with everything then do an Application.Run on your MDI form.
Public Sub Main
dim fSplash as new YourSplash()
dim fLogin as new YourLogin()
dim fMDI as new yourMDI()
fSplash.Show
if fLogin.ShowDialog()=False then
End
end if
fMDI.Show
fSplash.Close
Application.Run(fMDI)
End Sub
or something like that
in the module create a method "Main"
Public Sub Main
End Sub
Edit project properties so the startup object is Sub Main
Now within Sub main do what ever you need to do with your splash and login forms and when you are finally settled in with everything then do an Application.Run on your MDI form.
Public Sub Main
dim fSplash as new YourSplash()
dim fLogin as new YourLogin()
dim fMDI as new yourMDI()
fSplash.Show
if fLogin.ShowDialog()=False then
End
end if
fMDI.Show
fSplash.Close
Application.Run(fMDI)
End Sub
or something like that
Had a bit more of a look at it
Create a module with a sub Main and set your startup to sub main
In sub main create form1
dim frm1 as new Form1
frm1.show
Then when you close frm1 later, it should only close the form not the project.
frm1.close
frm1.dispose
Brian.
Create a module with a sub Main and set your startup to sub main
In sub main create form1
dim frm1 as new Form1
frm1.show
Then when you close frm1 later, it should only close the form not the project.
frm1.close
frm1.dispose
Brian.
Sorry - go with Sagebrush's answer.
ASKER
ok that didn't work right
So I am going to have just a login form and a mdi form
What was happening was if a user hit the ok button on the login form and the user information wasn't right it was closing the program. Also if a user hit cancel on the form it would open the mdi form.
confussing
What I have is a login form that has to show up 1st, then if the user gets the password correct then the mdi would open and the login form would close
if the user hits the cancel button it would just close the whole program.
I hope the new visual basic 2005 is better. This should be so easy and they made it a mess.
should just be
mdi.show
unload frmlogin
I miss vb 6
So I am going to have just a login form and a mdi form
What was happening was if a user hit the ok button on the login form and the user information wasn't right it was closing the program. Also if a user hit cancel on the form it would open the mdi form.
confussing
What I have is a login form that has to show up 1st, then if the user gets the password correct then the mdi would open and the login form would close
if the user hits the cancel button it would just close the whole program.
I hope the new visual basic 2005 is better. This should be so easy and they made it a mess.
should just be
mdi.show
unload frmlogin
I miss vb 6
fSplash.Show
if fLogin.ShowDialog()=False then
End
end if
should have been
if fLogin.ShowDialog()=Dialog Result.OK Then
and you have to handle the login ok click and establish dialogresults if the login was successful
if successfulLogin then
me.DialogResults=DialogRes ults.OK
me.Hide
end if
if fLogin.ShowDialog()=False then
End
end if
should have been
if fLogin.ShowDialog()=Dialog
and you have to handle the login ok click and establish dialogresults if the login was successful
if successfulLogin then
me.DialogResults=DialogRes
me.Hide
end if
ASKER
still not working, please exclude the splash screen and show me exactly I am suppose to place the code.
Sorry for the trouble
The reason why it when the login box comes up and the user types the username and password and if it is wrong it closes the whole program, if the user click the ok button without typing anything it lets them into the program and that is not suppose to happen.
I am about to just give up...
Sorry for the trouble
The reason why it when the login box comes up and the user types the username and password and if it is wrong it closes the whole program, if the user click the ok button without typing anything it lets them into the program and that is not suppose to happen.
I am about to just give up...
show me your sub main code and your login dialog buttonok click code
ASKER
Public Sub Main
dim fLogin as new YourLogin()
dim fMDI as new yourMDI()
flogin.show
if fLogin.ShowDialog()=Dialog Result.OK Then
End
end if
fMDI.Show
Application.Run(fMDI)
End Sub
login form has a button on it called cbok
under it
private sub cbok_click
if txttextbox1.text = "TED" and txtpsd.text = "Admin" then
'need to open the fmdi form
else
'do nothing and make user try again
end if
end sub
dim fLogin as new YourLogin()
dim fMDI as new yourMDI()
flogin.show
if fLogin.ShowDialog()=Dialog
End
end if
fMDI.Show
Application.Run(fMDI)
End Sub
login form has a button on it called cbok
under it
private sub cbok_click
if txttextbox1.text = "TED" and txtpsd.text = "Admin" then
'need to open the fmdi form
else
'do nothing and make user try again
end if
end sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
perfect thank you so much for your help
but in VB6 you would
unload formname
Brian.