Results 1 to 4 of 4

Thread: [RESOLVED] [2005] MakedTextBox Time Validation

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    Köln
    Posts
    395

    Resolved [RESOLVED] [2005] MakedTextBox Time Validation

    Greetings,

    I am using a MaskedTextBox. The Mask is 90:00 Time of the Type DateTime.

    How can I make sure the user is not entering 30:99 or something else users normaly try

    I also get a little bit confused should I use the Validating Event or the TypeValidationComleted Event?


    Thanks in advance
    Last edited by Bongo; Feb 12th, 2007 at 08:24 AM.

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    Köln
    Posts
    395

    Re: [2005] MakedTextBox Time Validation

    Found a regular expression pattern on the net


    Code:
    ^([0-1][0-9]|[2][0-3]):([0-5][0-9])$
    but I never used RegExpr.

    Help would be great. thx

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: [2005] MakedTextBox Time Validation

    Don't use a MaskedTextBox or a Regex for time. Use a DateTimePicker. Set the Format to Time or Custom if you don't want the standard time format. If you want 24 hour time then set the CustomFormat to "HH:mm". Finally set the ShowUpDown to True so there's no drop-down calendar. There's now no validation needed because the control handles it all for you. You get a DateTime object from the control's Value property. If you want a TimeSpan object then get the Value.TimeOfDay property.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    Hyperactive Member
    Join Date
    May 2001
    Location
    Köln
    Posts
    395

    Re: [2005] MakedTextBox Time Validation

    @jmcilhinney:

    Many thanks for your idea. Does exactly what i wanted

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width