djoyceRRD
asked on
How do I validate that a correct format was entered?
I have a windows form with a textbox tbLength that displays a length of time for a scheduling program. The user can enter a start date/time from a time picker field, and can enter a length - the combo of these 2 calculates the end date/time. I need Length to be in a proper timespan format 1.00:00:00, etc. How can I validate the entered value is OK? Can I force the entered format to be 99.99:99:99?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks! TryParse was exactly what I was looking for.
Imports System.Text.RegularExpress
Function IsValidTime(ByVal strIn As String) As Boolean
' Return true if strIn is in valid SSN format.
Return Regex.IsMatch(strIn, "^\d{2}:\d{2}:\d{2}$")
End Function