How to Clear the Text of MaskedEdit Control w/o Clearing Mask
Article ID: 117263
Article Last Modified on 10/29/2003
APPLIES TO
- Microsoft Visual Basic 3.0 Professional Edition
- Microsoft Visual Basic 3.0 Professional Edition
This article was previously published under Q117263
Traditionally, to clear the text of a MaskedEdit control, you would set
the control's Mask Property to an empty string, and then set its text
property to an empty string:
MaskedEdit1.Mask = ""
MaskedEdit1.Text = ""
Here's a better method. Modify the Mask property according to the following
steps. Then assign the Mask property to the text property of the MaskedEdit
control:
- Replace Every occurrence of the pound sign (#) or question mark (?) in
the Mask string with an underscore (_). The underscore is the default
value for PromptChar.
- Retain the literal characters and any spaces in the Mask string in their
original positions.
For Example, if the Mask property has this value:
(###) ###-#### Ext(#####)
and the PromptChar value is an underscore (_), use the following piece of
code to clear all the text and set the focus back to the MaskedEdit
control:
MaskedEdit1.Text = "(___) ___-____ Ext(_____)"
MaskedEdit1.SetFocus
Additional query words: 3.00 formatted format MaskEdit Masked Edit
Keywords: KB117263