FIX: Extra Chars in Masked Edit Cause Empty InvalidText Box (95508)



The information in this article applies to:

  • Microsoft Visual Basic Professional Edition for Windows 2.0

This article was previously published under Q95508

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.

Modification Type:MinorLast Reviewed:1/8/2003
Keywords:kbbug KB95508