Microsoft KB Archive/150188

= FIX: Masked Edit Control Replaces Input if PromptChar Changed =

Article ID: 150188

Article Last Modified on 7/16/2004

-

APPLIES TO


 * Microsoft Visual Basic 4.0 Standard Edition
 * Microsoft Visual Basic 4.0 Professional Edition
 * Microsoft Visual Basic 4.0 Professional Edition
 * Microsoft Visual Basic 4.0 16-bit Enterprise Edition
 * Microsoft Visual Basic 4.0 32-Bit Enterprise Edition

-



This article was previously published under Q150188



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



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: kbbug kbfix KB150188

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.