The Text property of the Masked Edit control does not work at run time in Visual Basic .NET or in Visual Basic 2005 (814321)



The information in this article applies to:

  • Microsoft Visual Basic 2005
  • Microsoft Visual Basic .NET (2003)
  • Microsoft Visual Basic .NET (2002)

Beta Information

This article discusses a Beta release of a Microsoft product. The information in this article is provided as-is and is subject to change without notice.

No formal product support is available from Microsoft for this Beta product. For information about how to obtain support for a Beta release, see the documentation that is included with the Beta product files, or check the Web location from which you downloaded the release.

SYMPTOMS

In Visual Basic .NET or Visual Basic 2005, you cannot access the text that you type in the Masked Edit control by using the Text property. The text that you assign to the Masked Edit control by using the Text property is not visible on the control. However, you can access the text by using the Text property if the text is assigned by using the Text property.

CAUSE

The Text Property is a non-browsable property of the Masked Edit control. The Masked Edit control is a Component Object Model (COM) control that you can only access through a COM Interop Wrapper. The Text property does not read the text that you type in the Masked Edit control, because the Text property is not hooked to the underlying OCX control. You cannot access the Text property in Microsoft Visual C# .NET or in Microsoft Visual C# 2005.

WORKAROUND

To work around this problem, use the CtlText property instead of the Text property. The Masked Edit control uses the CtlText property to set the text that you type in the Masked Edit control. For example, you can use AxMaskEdBox1.CtlText = "0123" instead of AxMaskEdBox1.Text = "0123".

STATUS

This behavior is by design.

MORE INFORMATION

Steps to Reproduce the Behavior

  1. Open Microsoft Visual Studio .NET or Microsoft Visual Studio 2005.
  2. On the File menu, point to New, and then click Project.
  3. Under Project Types, click Visual Basic Projects.
  4. Under Templates, click Windows Application.

    Note In Visual Studio 2005, click Visual Basic under Templates.

    By default, Form1 is created.
  5. Right-click Toolbar, and then click Customize Toolbox.

    Note In Visual Studio 2005, right-click Toolbar, and then click Choose Items.
  6. Click the COM Components tab.
  7. Locate and then click to select the Microsoft Masked Edit Control version 6.0 check box. Click OK.

    Notice that Masked Edit Control is added to the toolbar.
  8. Drag a Masked Edit control onto Form1.
  9. Drag a button onto Form1.
  10. Double-click Button1 to view the Code window for the Button1_click event.
  11. Add the following code in the Button1_click event:
    MsgBox(AxMaskEdBox1.Text)
  12. On the Debug menu, click Start to run the application.
  13. Enter text in the Masked Edit Control box, and then click Button1.

    A dialog box without text is displayed.
  14. Close Form1.
  15. Replace the existing code in the Button1_click event with the following code:
    AxMaskEdBox1.Text = "ABCD"
    MsgBox(AxMaskEdBox1.Text)
  16. On the Debug menu, click Start.
  17. Run the project, and then click Button1.
  18. ABCD dialog box is displayed. Click OK.

    Notice that the text in the Masked Edit control on the form is not changed to ABCD.

REFERENCES

For more information, visit the following Microsoft Web site:

Masked Edit Control

http://msdn.microsoft.com/library/en-us/masked/html/vbobjMaskEdit.asp

Modification Type:MinorLast Reviewed:10/3/2006
Keywords:kbvs2005applies kbvs2005swept kbprb kbWindowsForms kbEditCtrl kbCOMInterop kbControl KB814321 kbAudDeveloper