E
Ed Bitzer
I am trying to ascertain the value of the Error Provider Control and
it does identify the control failing validation without any extra code
but I cannot figure how to abort if the user throws in the towel and
cannot correct during the session. The following is my basic
structure and EmailAddressOK is simply and function assessing whether
or not the content of TextBox1 is valid. Move off TextBox1 and the
Validating sub takes charge and will not let go<g>. Once found
invalid how do I abort?
Private Sub TextBox1_Validating(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles TextBox1.Validating
Dim address As String = ""
Dim msg As String = ""
Try
If Not EmailAddressOK(TextBox1.Text, address, msg) Then
' Cancel the event and select the text to be corrected
by the user.
e.Cancel = True
TextBox1.Select(0, TextBox1.Text.Length)
' Set the ErrorProvider error with the text to
display.
Me.ErrorProvider1.SetError(TextBox1, msg)
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub TextBox2_Validated(ByVal sender As Object, ByVal e As
System.EventArgs) Handles TextBox2.Validated
Me.ErrorProvider1.SetError(TextBox2, "")
End Sub
Appreciate,
Ed
it does identify the control failing validation without any extra code
but I cannot figure how to abort if the user throws in the towel and
cannot correct during the session. The following is my basic
structure and EmailAddressOK is simply and function assessing whether
or not the content of TextBox1 is valid. Move off TextBox1 and the
Validating sub takes charge and will not let go<g>. Once found
invalid how do I abort?
Private Sub TextBox1_Validating(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles TextBox1.Validating
Dim address As String = ""
Dim msg As String = ""
Try
If Not EmailAddressOK(TextBox1.Text, address, msg) Then
' Cancel the event and select the text to be corrected
by the user.
e.Cancel = True
TextBox1.Select(0, TextBox1.Text.Length)
' Set the ErrorProvider error with the text to
display.
Me.ErrorProvider1.SetError(TextBox1, msg)
End If
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub TextBox2_Validated(ByVal sender As Object, ByVal e As
System.EventArgs) Handles TextBox2.Validated
Me.ErrorProvider1.SetError(TextBox2, "")
End Sub
Appreciate,
Ed