Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

validate time format

Status
Not open for further replies.

jass1220

Programmer
May 20, 2003
88
AE
am trying to validate the the time to be in this format .. the code is correct except the last if statement.. i want it to check that the ":" is the third digit from the right ..
///////////////

If Len(Text1.Text) < 4 Then
MsgBox (&quot;Time should be in this formate 0:00&quot;)
Else

If InStr(Text1, &quot;:&quot;) = 0 Then
MsgBox (&quot;Time should be in this formate 0:00&quot;)
Else

If InStr(&quot;:&quot;, Left(Trim(Text1), 1)) <> 0 Then
MsgBox (&quot;Time should be in this formate 0:00&quot;)
Else
If InStr(&quot;:&quot;, Right(Trim(Text1), 1)) <> 0 Then
MsgBox (&quot;Time should be in this formate 0:00&quot;)
Else
If InStr(&quot;:&quot;, Right(Trim(Text1), 3)) <> 0 Then
MsgBox (&quot;Time should be in this formate 0:00&quot;)
End If
End If
End If
End If
End If

///////////
 
Don't make it so difficult.

Just make sure the string has two semi-colons (use InStr - do not need to check where they are in the string) and if it is a date (if the semi-colons are not in the correct place, it is not a Date/Time)...
Or use a string &quot;Like&quot; comparison.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top