Results 1 to 5 of 5

Thread: Using MaskEdBox

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2001
    Location
    Vietnam
    Posts
    613

    Using MaskEdBox

    In MaskEdBox, I have the following code:

    Code:
    medDOB.Mask = "##/##/##"
    medDOB.Text = Format(rstPlayer!sgcusbdate, "ddddd")
    Now if the date part is less than 10, then it display only 1 integer, but the Mask expect 2 integer. So error occur.

    How can I make sure that the datepart is always 2 integers? (Note: I must use dateformat "ddddd" ie. vbshortdate since this is an international app.)

    Thanks.

  2. #2
    PowerPoster
    Join Date
    Aug 2000
    Location
    IN SILENCE
    Posts
    6,441

    Since you like using controls

    Why not use a DTpicker? It will always give you a valid date...
    Remaining quiet down here !!!

    BRAD HAS GIVEN ME THE ULTIMATIVE. I have chosen to stay....

  3. #3
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Well ...

    Originally posted by TheBao
    In MaskEdBox, I have the following code:

    Code:
    medDOB.Mask = "##/##/##"
    medDOB.Text = Format(rstPlayer!sgcusbdate, "ddddd")
    Now if the date part is less than 10, then it display only 1 integer, but the Mask expect 2 integer. So error occur.

    How can I make sure that the datepart is always 2 integers? (Note: I must use dateformat "ddddd" ie. vbshortdate since this is an international app.)

    Thanks.
    Here is how I use a MaskEdBox in code:

    VB Code:
    1. Dim tmpMask As String
    2. tmpMask = MaskEdBox1.Mask
    3. MaskEdBox1.Mask = ""
    4. MaskEdBox1.Text = <Some value goes here>
    5. MaskEdBox1.Mask = tmpMask

    To put it simply, you extract the existing mask into a temporary variable, remove the mask, then set the text and reset the mask using the temporary variable. I am sure this will do the trick for you.

    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    Jan 2001
    Location
    Vietnam
    Posts
    613
    Thank you. Actually, what I want is more than that.

    I don't know before hand what the format of the date on the user machine is. So I end up have to get this from the regional setting, then convert this to the mask string for the MaskEdBox.

    Thanks.

  5. #5
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Well ...

    Can you retrieve the format from the regional settings? Converting it to a Mask value is your problem? Or once the mask is set, displaying data in that format is a problem?

    I guess you can use the "Short Date" in the Format() function to format the date as per the user's regional settings. If the problem is the second one, I can help.

    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

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