Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: .NET VB.NET login
How to close main form i. e login form after login and it should not close application
Posted 14-Jun-12 1:51am
Edited 14-Jun-12 1:52am
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

From Google results:
 
http://www.dreamincode.net/forums/topic/97089-main-form-closing-after-login/[^]
 
The last answer might help.
  Permalink  
Comments
Sandeep Mewara at 14-Jun-12 10:35am
   
There are couple of comments by OP for you posted as an answer. Please have a look at them. Did not copy-pasted as there were codes in it .
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

check your form name first, if it is alright then try the following. I may be wrong but i guess it might work.
 
if mainform.show()then
loginform1.close()
else
...
end if
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

Simple really. You main from should NOT be your login form.
 
Your main form should be, well, the main form of your application. It should determine that a login is required, then create and show the login form.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

@krumia thanks for a short reply..but i have to call or name all the functions i.e
If rowsEffected > 0 Then
2
    cnMySQL.Close()
3
    MainForm.Show()
4
    LoginForm1.Close()
5
Else
6
    cnMySQL.Close()
7
    MsgBox("Login Failed!")
8
End If
 
what should i do.it didn't work..pls help...
see my first form is very simple i. e login details thats it. so after login my login details form should hide when second form opens
  Permalink  
Comments
Sandeep Mewara at 14-Jun-12 10:33am
   
This is not an answer. Please use 'Have a Question or Comment' link to respond to an answer. It will notify answerer of your comment such that he can come back and reply.
krumia at 14-Jun-12 10:49am
   
Did you read the 'last answer'? I asked you to look at the last answer: It says "Try setting the Application Properties to fix this. Try changing Shutdown Mode to 'When last form closes'. This will keep the program open until all forms are closed."
 
I did not want to copy it here and make it look like my own answer. That's why I sent you the link and told you to look at the last answer.
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

This is my code
Private Sub btnLogin_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLogin.Click
        If txtUserID.Text = "admin" Then
        End If
        If txtPass.Text = "admin" Then
            Form2.Show()
        Else
            MsgBox("password is incorrect")
            Exit Sub
            MsgBox("You have now gained access")
 
        End If
    End Sub
 
now i want to close this form and open up new form.pls help
  Permalink  
Comments
Sandeep Mewara at 14-Jun-12 10:32am
   
This is not an answer. Please use 'Have a Question or Comment' link to respond to an answer. It will notify answerer of your comment such that he can come back and reply.
ahmed youness11 at 18-Aug-12 4:47am
   
How to Exit the main form after the password failed

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Kornfeld Eliyahu Peter 275
1 Maciej Los 214
2 Sergey Alexandrovich Kryukov 200
3 King Fisher 185
4 OriginalGriff 163
0 OriginalGriff 6,223
1 DamithSL 4,724
2 Maciej Los 4,196
3 Kornfeld Eliyahu Peter 3,894
4 Sergey Alexandrovich Kryukov 3,496


Advertise | Privacy | Mobile
Web02 | 2.8.141220.1 | Last Updated 14 Jun 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100