-
Validation Command
Hi,
I have the following validation which works fine for numeric textbox i.e., txtprojstart, however I want to update it for datetime textbox instead of numeric any help please... See code below
Code:
Private Sub txtprojstart_Validating(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles txtprojstart.Validating
If Not IsNumeric(txtprojstart.Text) And txtprojstart.Text <> "" Then
' Cancel the event moving off of the control.
e.Cancel = True
' Select the offending text.
txtprojstart.Select(0, txtprojstart.Text.Length)
' Give the ErrorProvider the error message to display.
ErrorProvider.SetError(txtprojstart, "Enter correct date format")
End If
End Sub]
Code:
Private Sub txtprojstart_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtprojstart.Validated
ErrorProvider.SetError(txtprojstart, "")
End Sub
thanks
-
Re: Validation Command
Any reason why you are not just using numeric up/down controls and date/time calender control?
In case you really need it there is an IsDate method just like the IsNumeric.