Results 1 to 4 of 4

Thread: Forcing entry of date in text box?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,091
    Hi,

    I have a text box that I only want a date entered in to. But, what else I would like to do is as the user is typing, the / signs automatically get placed after the month and year..

    It's just kindof a nice feature to have and I have seen it done before.. Access seems to have this built in but I can't figure it out in VB6.

    I understand that there might be a control that does this, but would rather do it in code so I don't have to distribute another control..

    Thanks,

    Dan

  2. #2

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Posts
    1,091
    In thinking about my question some more, forget about automatically entering the / signs.. I guess it's not like a phone number where it is a fixed number of digits..

    But, what I would like is some code that checks to make sure the user entered a valid date and if not, pop up a msgbox..

    Thanks,

    DAn

  3. #3
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Code:
    Private Sub Text1_LostFocus()
    'IsDate checks if the expression is a valid date
    If IsDate(text1.text) = False Then
        MsgBox "Please enter a valid date
    End if
    End sub
    
    '>>>USAGE<<<
    'IsDate("hahaha") = False
    'IsDate(22-22-00) = False
    'IsDate(021000) = False
    'IsDate("02.10.00") = True
    'IsDate(02-10-00) = True
    'IsDate(02/10/00) = True
    [Edited by Jop on 10-02-2000 at 01:13 PM]
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  4. #4
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Replace the textbox with a MaskEdBox

    Set the MaskedBox Mask property to ####/##/##
    Include literals

    then nothing but nambers can be entered and the
    box will read yyyy/mm/dd

    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

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