FIX: Masked Edit Control Replaces Input if PromptChar Changed
ID: Q150188
|
The information in this article applies to:
-
Microsoft Visual Basic Standard, Professional, and Enterprise Editions, 16-bit and 32-bit, for Windows, version 4.0
SYMPTOMS
Any input characters inside the Masked Edit control when the PromptChar
character is changed are converted to the new PromptChar in the 32-bit
edition of Visual Basic, and are deleted in the 16-bit edition.
STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed
at the beginning of this article. This bug has been fixed in Visual Basic
6.0.
WORKAROUND
Store the text inside the Masked Edit control before changing the
PromptChar and restoring the saved text to the control after it has
changed.
Rather than change the PromptChar, call the following subroutine to modify
it:
Public Sub ChangePromptChar(ByVal cNewChar As String)
Dim strClip As String
strClip = MaskEdBox1.ClipText
MaskEdBox1.PromptChar = cNewChar
MaskEdBox1.SelStart = 0
MaskEdBox1.SelText = strClip
End Sub
MORE INFORMATION
Steps to Reproduce Problem
- Start a new project in Visual Basic. Form1 is created by default. Place
a Masked Edit box on to Form1. In the Load event of Form1, place the
following code:
Private Sub Form_Load()
MaskEdBox1.Mask = "&&"
End Sub
- In the Click event of Form1, place the following code:
Private Sub Form_Click()
MaskEdBox1.PromptChar = "o"
End Sub
- Run the project by pressing F5. Type "gg", for example, into the Masked
Edit control, and then click on the form. The existing characters are
transformed to the prompt character "o" in the 32-bit edition, and
deleted in the 16-it edition.
To fix this problem, use the subroutine in the Workaround Section above,
and then change the Click event of Form1 to:
Private Sub Form_Click()
ChangePromptChar "o"
End Sub
Additional query words:
kbVBp400bug kbVBp600fix kbdss kbDSupport kbVBp kbControl
Keywords : kbGrpVB
Version :
Platform : NT WINDOWS
Issue type : kbbug