Results 1 to 3 of 3

Thread: Fix the Input DATE

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 1999
    Posts
    16

    Wink

    Hi
    I'm using Maskeditbox control for user input, I set the mask property = "##-##-####" and format property = "dd-mmm-yyyy", when a user keys in
    16-02-2000, the input data would soon be changed to 16-Feb-2000 as the control lost focus, conversely, if the user mistakenly keys in
    32-08-2000, the input data won't be changed to
    32-Aug-2000 as long as it's invalid. It's good for me to validate the user's input, but if the user keys in 08-31-2000, the input data would also be changed to 31-Aug-2000, meaning that 31-08-2000 and 08-31-2000 are both acceptable as being validated with IsDate() function. I just want 31-08-2000 to be the VALID INPUT DATE while validating with IsDate() function, how can I solve this problem ? (I'd already set the regional setting to English(United Kingdom).
    Thanx.

  2. #2
    Addicted Member
    Join Date
    Sep 1999
    Location
    Philippines
    Posts
    196

    Talking

    Why don't you use the date picker control. Its the best OCX for having input dates.

    Still, if you want the edit mask control, you might have to create your own validation date function in your MODULE. Don't forget about leap years!

    Hope this helps.

  3. #3
    Addicted Member
    Join Date
    Sep 2000
    Posts
    138
    The following code might be of some help to you.

    Code:
    ____________________________________________________________
    ¡®Create a new project.
    ¡®Draw two TextBoxes with their default names

    Private Sub Text1_Validate(KeepFocus As Boolean)

    If Not IsDate(Text1.Text) Then
    MsgBox "Invalid Date! Enter again.", vbOKOnly + vbExclamation, "Key in Date"
    KeepFocus = True
    Text1.SelStart = 0
    Text1.SelLength = Len(Text1.Text)
    Else
    Text1.Text = Format(Text1.Text, "dd-mm-yyyy")
    Text2.Text = Format(Text1.Text, "mm-dd-yyyy")
    KeepFocus = False
    End If

    End Sub
    ____________________________________________________________

    When we enter a date in TextBox1 (for example, 20-10-2000)and TextBox1 loses focus, we get two dates different in format in the two TextBoxes, i.e., ¡°20-10-2000¡± and ¡°10-20-2000¡±, whatever the locale.

    ____________________________________________________________
    Visual Basic Professional 6.0

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