Results 1 to 4 of 4

Thread: Textbox Date Format

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2000
    Location
    Greenville
    Posts
    73

    Post

    Can anyone tell me how to format a textbox so that when it gets focus and loses focus that it gets the mask for the short date, "dd,mm,yyyy", that someone will enter?? I need help with this easy one. Thanks.

  2. #2
    Member
    Join Date
    Jan 1999
    Location
    Longmont,CO
    Posts
    53

    Post

    Why not use the masked edit control? You can then set the mask to whatever you like and still grab the text without a mask. Add the Microsoft Masked Edit Control to your toolbox and then add one to the form.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 2000
    Location
    Greenville
    Posts
    73

    Post

    I wanted to see what else I could do in code because I already have my txtboxes in place and in different parts of my code.

  4. #4
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    Sure.

    Code:
    Private Sub Text1_LostFocus()
        If IsDate(Text1.Text) Then
            Text1.Text = Format(Text1.Text, "mm,dd,yyyy")
        End If
    End Sub
    As you can see, I'm also checking if the text the user enters is a valid date.

    ------------------

    Serge

    Senior Programmer Analyst
    [email protected]
    [email protected]
    ICQ#: 51055819

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