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???


peanut1010Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

brianb99999Commented:
not sure in VB.NET,

but in VB6 you would
unload formname

Brian.
0
sagebrushCommented:
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













0
brianb99999Commented:
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.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

brianb99999Commented:
Sorry - go with Sagebrush's answer.
0
peanut1010Author Commented:
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
0
sagebrushCommented:
fSplash.Show
  if fLogin.ShowDialog()=False then
    End
  end if


should have been

  if fLogin.ShowDialog()=DialogResult.OK Then


and you have to handle the login ok click and establish dialogresults if the login was successful

if successfulLogin then
  me.DialogResults=DialogResults.OK
  me.Hide
end if

0
peanut1010Author Commented:
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...

0
sagebrushCommented:
show me your sub main code and your login dialog buttonok click code
0
peanut1010Author Commented:
Public Sub Main
    dim fLogin as new YourLogin()
  dim fMDI  as new yourMDI()

  flogin.show
   if fLogin.ShowDialog()=DialogResult.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
0
sagebrushCommented:
change this, remove the flogin.show line:

flogin.show << just remove this
   if fLogin.ShowDialog()=DialogResult.OK Then  << this ok
    End
  end if
 
change this to:

private sub cbok_click
      if txttextbox1.text = "TED" and txtpsd.text = "Admin" then
                me.dialogresult=dialogresult.ok
               me.hide
     end if

end sub
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
peanut1010Author Commented:
perfect thank you so much for your help
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.