AWestEng
asked on
Check if string is valid time
Hi
How can I chak for a vaild time and only for a time
DIm strTIme as string = "16:34"
If IsDate(strTIme ) And strTIme .Length = 5 Then
'OK
else
'Fault
End if
The probelm is that is also takes a date 05/05 => OK
How can I check that so it only approve the string if it's vaild time?
How can I chak for a vaild time and only for a time
DIm strTIme as string = "16:34"
If IsDate(strTIme ) And strTIme .Length = 5 Then
'OK
else
'Fault
End if
The probelm is that is also takes a date 05/05 => OK
How can I check that so it only approve the string if it's vaild time?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Public Function IsTime(ByVal Time As Object) As Boolean
'*************************
'* This subroutine determines if a value is a valid time
'* (not date).
'*************************
If IsDate(Time) = True Then
If CStr(Time) Like "*#*.*#*" = False Then
If Fix(CDate(Time)) = 0 Then
If CStr(Time) Like "1[3-9]*[aApP]*" = False Then
If CStr(Time) Like "2[0-3]*[aApP]*" = False Then
IsTime = True
End If
End If
End If
End If
End If
End Function