Microsoft KB Archive/814321

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

Article ID: 814321

Article Last Modified on 11/13/2007

-

APPLIES TO


 * Microsoft Visual Basic 2005
 * Microsoft Visual Basic .NET 2003 Standard Edition
 * Microsoft Visual Basic .NET 2002 Standard Edition

-





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  instead of.



STATUS
This behavior is by design.



Steps to Reproduce the Behavior
 Open Microsoft Visual Studio .NET or Microsoft Visual Studio 2005. On the File menu, point to New, and then click Project. Under Project Types, click Visual Basic Projects. Under Templates, click Windows Application.

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

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

Note In Visual Studio 2005, right-click Toolbar, and then click Choose Items.</li> Click the COM Components tab.</li> 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.</li> Drag a Masked Edit control onto Form1.</li> Drag a button onto Form1.</li> Double-click Button1 to view the Code window for the Button1_click event.</li>  Add the following code in the Button1_click event: MsgBox(AxMaskEdBox1.Text) </li> On the Debug menu, click Start to run the application.</li> Enter text in the Masked Edit Control box, and then click Button1.

A dialog box without text is displayed.</li> Close Form1.</li>  Replace the existing code in the Button1_click event with the following code: AxMaskEdBox1.Text = &quot;ABCD&quot; MsgBox(AxMaskEdBox1.Text) </li> On the Debug menu, click Start.</li> Run the project, and then click Button1.</li> ABCD dialog box is displayed. Click OK.

Notice that the text in the Masked Edit control on the form is not changed to ABCD.</li></ol>

<div class="references_section">