FIX: Extra Chars in Masked Edit Cause Empty InvalidText Box

Last reviewed: October 30, 1997
Article ID: Q95508
2.00 WINDOWS kbprg kbbuglist

The information in this article applies to:

- Professional Edition of Microsoft Visual Basic for Windows, version 2.0

SYMPTOMS

Entering more characters than specified in the Mask property of a Masked Edit control generates a ValidationError event, and the InvalidText parameter is set to the empty string.

The InvalidText parameter should be set to the value of the Text property for the masked edit control, including the invalid character.

STATUS

Microsoft has confirmed this to be a bug in the Professional Edition of Microsoft Visual Basic version 2.0 for Windows. This problem was partially corrected in Microsoft Visual Basic version 3.0 for Windows. In version 3.0, the InValidText returned has only as many characters as allowed by the Mask. For example, if the Mask is "##" and you type "123" the InvalidText returned is "12"

MORE INFORMATION

Steps to Reproduce Problem

  1. Start Visual Basic or from the File menu, choose New Project (ALT, F, N) if Visual Basic is already running. Form1 is created by default.

  2. From the File menu, choose Add File. In the Files box, select the MSMASKED.VBX custom control file. The Masked Edit tool appears in the Toolbox. In Visual Basic version 3.0, MSMASKED.VBX is automatically installed.

  3. Add a masked edit control (MaskedEdit1) to Form1 and change its Mask property to ##.

  4. Add the following code to MaskedEdit1_ValidationError:

       Sub MaskedEdit1_ValidationError (InvalidText As String,
          StartPosition As Integer) 'This must be on a single line.
          MsgBox InvalidText
       End Sub
    
    

  5. From the Run menu, choose Start (ALT, R, S) to run the program.

  6. Type 123 into the masked edit control.

At this point, you'll see an empty message box. Instead of being empty, the message box should display "12" -- the masked portion of the "123" entered in step 6.


Additional reference words: buglist2.00 fixlist3.00 2.00 3.00 blank
KBCategory: kbprg kbbuglist
KBSubcategory: PrgCtrlsCus
Solution Type : kbfix


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 30, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.