BUG: Masked Edit Control Replaces Input if PromptChar Changed

Last reviewed: October 11, 1996
Article ID: Q150188
The information in this article applies to:
  • Standard, Professional, and Enterprise Editions of Microsoft Visual Basic for Windows, 16-bit and 32-bit, 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 an issue in the Microsoft products listed at the beginning of this article. Microsoft is researching this issue and will post new information here in the Microsoft Knowledge Base as it becomes available.

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

  1. 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
    
    

  2. In the Click event of Form1, place the following code:

       Private Sub Form_Click()
       MaskEdBox1.PromptChar = "o"
       End Sub
    
    

  3. 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 reference words: 4.00 vb4win vb4all
KBCategory: kbprg kbbuglist
KBSubcategory: PrgCtrls



THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: October 11, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.