Socarsky
Well-known member
I can validate a textbox's value whether it's has or not and then event of saving button does its task to pass the data through database.
At the point I wonder there is a better method to do that? or How can I stop the save button event to run if that validation condition occurs fail?
At the point I wonder there is a better method to do that? or How can I stop the save button event to run if that validation condition occurs fail?
VB.NET:
Dim bValidateZipCode As Boolean
Private Sub txtZipCode_Leave(sender As Object, e As EventArgs) Handles txtZipCode.Leave
If Not IsNumeric(txtZipCode) OrElse (txtZipCode.TextLength = Nothing) Then
ErrorProvider1.SetError(txtZipCode, "Provide a zip code")
Else
bValidateZipcode = True
End If
End Sub
Last edited: