Returns or sets the input mask used to edit cells.
[form!]VSFlexGrid.EditMask[ = value As String ]
The EditMask property allows you to specify an input mask for automatic input formatting and validation. The mask syntax is similar to the one used by the Microsoft MaskedEdit control and by Microsoft Access.
When the user is done editing, the ValidateEdit event will be fired as usual. The Cancel parameter will be set to True if the mask was not filled out properly, so in most cases you don't event need to implement the handler. The default behavior ensures that only valid data will be entered.
The EditMask must be a string composed of the following symbols:
9 digit or space
# digit or sign
? letter or space
A letter or digit
a letter, digit, or space
& any character
. localized decimal separator
, localized thousand separator
: localized time separator
/ localized date separator
\ next character is taken as a literal (not a special character)
> translate letters to uppercase
< translate letters to lowercase
; group delimiter (see below)
The group delimiter character is used to control additional options. If present in the mask string, then the part of the mask to the left of the first delimiter is used as the actual mask. The part to the right is interpreted in this way:
If a lowercase 'q' is present, the control edits in 'quiet' mode (no beeps on invalid characters),
The last character is used as a placeholder (instead of the default underscore).
' set the mask so the user can enter a phone number,
' with optional area code, and a state in capitals.
' this will beep on invalid keys.
fg.EditMask = "(###) 000-0000 St\ate\: >LL"
' similar mask, but in quiet mode (no beep for wrong keys)
' and with an asterisk instead of underscore for a placeholder:
fg.EditMask = "(###) 000-0000 St\ate\: >LL;q;*"
Here are some more commented examples:
Is a valid format. The 'a' and ';' characters are escaped and thus taken as literals. The '>' is used to ensure that the next two characters will be represented in uppercase.
Is a valid format. It is similar to the previous example, but the 'q' after the delimiter puts the control in quiet mode. An asterisk '*' is used as placeholder instead of the underscore, because that is the last character after the delimiter.
This is an invalid format. The mask itself is just "St" (the part to the left of the ';' delimiter. There are no wildcards, so the user can't type anything. If he could, the placeholder character would be "L" (last character after the ';' delimiter).
This is an invalid format. The first character is a delimiter, so there is no real mask at all.