The Mask editing box (Maskedit) is a special edit box. Use it to design a number of complex input formats. After selecting Maskedit, you need to design an input format for it. The method is as follows:
First select the Maskedit on the form, locate the Editmask property in the Object Viewer (Objects Inspector), double-click it, and pop up a dialog box as shown in the following figure.
The Input mask edit box in the upper-left corner of the dialog box is used to enter the mask format. The mask format can be divided into three parts, each part separated by a semicolon ";", such as "!90:90:90:;1;_". The following explains the meaning of each input format character:
1. The first part of the input format is the mask itself, which is the data entry format. In this section, some special formatting characters are used to indicate the type and format of the character that should be entered, such as a string of input format masks such as "!l0a9:c>ll<". The commonly used Maskedit input format characters are:
Format character |
Significance |
L and L |
L indicates that the position is only a single letter and can be skipped with the cursor key, but it cannot be another type of character. L The position must be a character. |
A and a |
A indicates that the location can only be one letter or number character. A indicates that the location must be a letter or numeric character. |
C and C |
C means that the position is only one letter, and C indicates that the position must have a letter. |
9 and 0 |
9 indicates that the position is only a number, and 0 indicates that the position must have a number. |
|
|
< & > |
The < format character indicates that subsequent letters are displayed in lowercase until a > format character or <> format symbol is encountered. The > Format character is just the opposite of <. |
〈〉 |
Indicates no capitalization conversion, whichever is the form of the input. |
\ |
The mask format character that represents the format character will be treated as a normal characters in the data. When a user wants to put a mask format character into the data, a \ symbol should be placed before the format character. such as \a,\\ and so on. |
# |
Indicates that the position may be a number or a positive symbol. |
! |
If there is! The space before the data will not be saved in the data, no! The space after the data is not saved. The format character can only be placed at the first character of the mask format symbol. |
; & / |
A standard separator that can be used as part of the data. where/when displayed as '-' rather than/. |
|
|
2. There are only 0 and 12 options in the second part of the input format. In the case of 1, other characters such as non-user input data and standard delimiters in the mask are saved as part of the data, and 0 are not saved.
3. The third part of the input format is used to indicate that the vacancy in the data replaces the display with that character.
With this knowledge, now is the time to design an example. For example, to enter a car brand such as CA-300019. The first two digits of the data are letters and uppercase, the third is a system separator, and the last 6 digits are digits. You can design mask formats like this:
!>ll/000000;1;_
The second part of the mask is 1 to indicate that the system separator '-' will also be saved as data. The third part of "_" means empty in the Mask edit box, using "_" to indicate the vacancy. We can also use a space to identify the vacancy.
Also such as a postcode such as PO-100083, where PO means that the post, is the prefix of each zip code, you can design the mask format:
! Po/000000;1;_
On the right side of the Mask Design dialog box is sample masks, which has a commonly used mask format for system presets, such as phone numbers (phones), dates, and so on. We can choose one, then make the necessary adjustments. The bottom left of the dialog box is a test input bar where we can enter characters to detect whether the input format is satisfactory.