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.