Click here to Skip to main content
15,891,372 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to close main form i. e login form after login and it should not close application
Posted
Updated 14-Jun-12 0:52am
v2

From Google results:

http://www.dreamincode.net/forums/topic/97089-main-form-closing-after-login/[^]

The last answer might help.
 
Share this answer
 
Comments
Sandeep Mewara 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 .
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
 
Share this answer
 
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.
 
Share this answer
 
@krumia thanks for a short reply..but i have to call or name all the functions i.e
VB
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
 
Share this answer
 
Comments
Sandeep Mewara 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 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.
This is my code
VB
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
 
Share this answer
 
Comments
Sandeep Mewara 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 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)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900