![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Nov 2004
Posts: 6
Rep Power: 0
![]() |
Hi all, Can anyone shed like on how I can validate a textbox to make sure its in the format hh.mm?
|
|
|
|
|
|
#2 |
|
I eat cake for breakfast.
![]() ![]() ![]() ![]() Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9
![]() |
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 SubThere'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. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|