Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 29th, 2004, 10:29 AM   #1
masanovic
Newbie
 
Join Date: Nov 2004
Posts: 6
Rep Power: 0 masanovic is on a distinguished road
Hi all, Can anyone shed like on how I can validate a textbox to make sure its in the format hh.mm?
masanovic is offline   Reply With Quote
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
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:01 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC