The ActiveX MaskEdit Control |
|
Microsoft Visual Basic 6.0 provides a convenient text box that allows you to
assist the user with text entry in a text box. This control is called MaskEdit.
To use this control, you must explicitly add it as a COM Component of the
Microsoft Masked Edit Control.
The most important property of a MaskEdit control, which sets it apart from the (traditional)
text box control, is its ability to control what the user can and cannot enter in the text side. To configure this text,
you have two alternatives. The Format property in the
Properties window provides a list of available masks you can use:
If none of the masks in the list suits you, you still have
two alternatives. You can type your own desired mask in the Format field.
The characters you can use are:
Date |
Format |
Used For |
Description |
d |
Days |
Displays the day as a number from 1 to 31 |
dd |
Days |
Displays the day as a number with a leading 0 if the number is less than 10 |
ddd |
Weekdays |
Displays a weekday name with 3 letters as Mon, Tue, etc |
dddd |
Weekdays |
Displays the complete name of a week day as Monday, etc |
M |
Months |
Displays the numeric month from 1 to 12 |
MM |
Months |
Displays the numeric month with a leading 0 if the number is less than 10 |
MMM |
Months |
Displays the short name of the month as Jan, Feb, Mar, etc |
MMMM |
Months |
Displays the complete name of the month as January, etc |
yy |
Years |
Displays two digits for the year as 00 for 2000 or 03 for 2003 |
yyyy |
Years |
Displays the numeric year with 4 digits |
Besides these letters, an empty space and/or a special
character should be used to separate the sections of the string. You should use
an appropriate character as defined in the Regional Settings of the Control
Panel:
Based on this, in US English, the character used to separate
the date sections is the forward slash if you use a short date. In US English,
the comma is used to separate the sections of a long date.
Time |
Format |
Used For |
Description |
h |
Hour for 12-hour basis |
Used to display the hour with one digit if the value is less than 10 |
hh |
Hour for 12-hour basis |
Used to display the hour with a leading 0 if the value is less than 10 |
H |
Hour for 24-hour basis |
Used to display the hour with one digit if the value is less than 10 |
HH |
Hour for 24-hour basis |
Used to display the hour with a leading 0 if the value is less than 10 |
m |
Minute |
Used to display the minute with one digit if the value is less than 10 |
mm |
Minute |
Used to display the minute with a leading 0 if the value is less than 10 |
t |
AM/PM |
Displays the letter A or P for the AM or PM section |
tt |
AM/PM |
Displays the letters AM or PM for the last section |
Besides the Format property, you can create a mask using the Mask
field of the Properties window. Both allow you to use many other characters to
create custom masks.
|
|