I am having some trouble with the Validating event on a form.
Here is my code to show the problem:
I have also tried:
If I try and close the form by clicking the Button_1, the form does not close. Why would this be? It seems that the Validation is still turned on. How can I turn this off?
Here is my code to show the problem:
Code:
Private Sub TextBox1_Validating(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles TextBox1.Validating
If TextBox1.Text = "" Then
e.Cancel = True
MsgBox("Please enter some text")
End If
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Me.AutoValidate = False
Me.Close()
End Sub
Code:
CausesValidation = False