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.

.