View Single Post
Old Nov 29th, 2004, 1:09 PM   #2
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
You could do:
Private Sub Text1_LostFocus()
   Dim error As Boolean
   Dim x As Integer
   
   If Len(Text1.Text) <> 5 Then
     error = True
   Else
     For x = 1 To Len(Text1.Text)
       If x <> 3 And IsDigit(Mid(Text1.Text, x, 1)) = False Then
         error = True
       ElseIf x = 3 And Mid(Text1.Text, x, 1) <> ":" Then
         error = True
       EndIf
   EndIf
  
  If error = True Then
    MsgBox "Error: please enter the data in the format HH:MM.", vbError, "Error"
   EndIf
End Sub

There's definitely a few bugs in this code and it's written for VB6, but it should give you an insight into what you need to do.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote