Can i get a function to validate time eneterd in a text box
Yes, the datetimepicker control has both good and bad points. It's not always appropriate.
One thing you might try, (not sure whether it's available in all versions) is the "Microsoft Masked Edit Control" (add in under
Project | Components). This allows you much more control over the input than a standard textbox. Of course, you may still need to validate afterward, but at least you can enforce the general format of the input.
As for validating, perhaps the simplest way is to turn on error handling and try to convert the value to a time. For example (VB6)...
- Dim T As Date
-
Dim S As String
-
' Assuming your value is in S...
-
On Error Resume Next
-
T = TimeValue(s)
-
If Err.Number Then
-
Err.Clear
-
' Not a valid time.
-
End If
-
On Error GoTo 0