Results 1 to 4 of 4

Thread: [RESOLVED] Valid date

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Sep 2008
    Posts
    1,260

    Resolved [RESOLVED] Valid date

    How can i check to see if the contents of a textbox is in the valid date format?

  2. #2
    Head Hunted anhn's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    3,669

    Re: Valid date

    If IsDate(TextBox1.Text) Then
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • If your question was answered please use Thread Tools to mark your thread [RESOLVED]
    • Don't forget to RATE helpful posts

    • Baby Steps a guided tour
    • IsDigits() and IsNumber() functions • Wichmann-Hill Random() function • >> and << functions for VB • CopyFileByChunk

  3. #3
    PowerPoster Ellis Dee's Avatar
    Join Date
    Mar 2007
    Location
    New England
    Posts
    3,530

    Re: Valid date

    vb Code:
    1. If IsDate(Text1.Text) Then
    2.     MsgBox "Valid Date"
    3. Else
    4.     MsgBox "Invalid Date"
    5. End If

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: [RESOLVED] Valid date

    Note that IsDate thinks that lots of things (such as "3/2010" and "0.13") are valid dates - while you probably don't.


    Unless you have a very good reason for using a textbox, I strongly suggest you use one of the alternatives shown in the article What controls can I use to input a date/time? from our Classic VB FAQs (in the FAQ forum). If you use a Date based control like the DTP, you don't need any checking at all.

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