Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

vb.net closing a form

Posted on 2004-11-04
11
Medium Priority
?
292 Views
Last Modified: 2010-04-17
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???


0
Comment
Question by:peanut1010
  • 4
  • 4
  • 3
11 Comments
 
LVL 5

Expert Comment

by:brianb99999
ID: 12498539
not sure in VB.NET,

but in VB6 you would
unload formname

Brian.
0
 
LVL 1

Expert Comment

by:sagebrush
ID: 12498550
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
 
LVL 5

Expert Comment

by:brianb99999
ID: 12498620
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Expert Comment

by:brianb99999
ID: 12498634
Sorry - go with Sagebrush's answer.
0
 

Author Comment

by:peanut1010
ID: 12507745
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
 
LVL 1

Expert Comment

by:sagebrush
ID: 12507880
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
 

Author Comment

by:peanut1010
ID: 12508746
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
 
LVL 1

Expert Comment

by:sagebrush
ID: 12508806
show me your sub main code and your login dialog buttonok click code
0
 

Author Comment

by:peanut1010
ID: 12510112
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
 
LVL 1

Accepted Solution

by:
sagebrush earned 120 total points
ID: 12510335
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
 

Author Comment

by:peanut1010
ID: 12510990
perfect thank you so much for your help
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
When you discover the power of the R programming language, you are going to wonder how you ever lived without it! Learn why the language merits a place in your programming arsenal.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question