Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,I want validation codes in vb.net for exit button in login form
I mean if i want to click exit button in login form -
it will show amessege ask me if i want to exit or no (yes,no)question
Posted
Updated 23-Feb-12 6:37am
v2
Comments
Uday P.Singh 23-Feb-12 12:08pm    
what does this suppose to be mean?
Varun Sareen 23-Feb-12 12:26pm    
means?
ZurdoDev 23-Feb-12 12:28pm    
Why do you want to validate someone trying to exit a login form? I think you need more details.

I'd use this because it will take care of any way that the form is being closed, even if it's the user clicking the x in the upper right corner.
VB
Private Sub Form1_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
    If MessageBox.Show("Do you want to exit?", "Exit?", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.No Then
        'User decided not to exit, cancel the form close
        e.Cancel = True
    End If
End Sub
 
Share this answer
 
Comments
Sander Rossel 23-Feb-12 14:06pm    
My 5.
We cannot answer that.

How would we know what you are trying to validate? Or what values are valid for your application?

Think about it: So far you have broken down while out for a drive. You have called a garage at random and said "My Car broke. Fix it." then put the phone down. Do you think you will be waiting long for a mechanic to arrive with all the parts and tools he needs?
 
Share this answer
 
Comments
Soiraian 23-Feb-12 12:43pm    
I mean when I click exit button in login form -
it will show amessege ask me if i want to exit or no (yes,no)question & yes or no has value
something like this?

VB
If MessageBox.Show("Do u want to exit?", "Exit the program", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
    Me.Close()
End If
 
Share this answer
 

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