MaskedTextBox.ValidateText Method

Converts the user input string to an instance of the validating type.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in

public Object ValidateText ()
public Object ValidateText ()
public function ValidateText () : Object
Not applicable.

Return Value

If successful, an Object of the type specified by the ValidatingType property; otherwise, a null reference (Nothing in Visual Basic) to indicate conversion failure.

Exception typeCondition


A critical exception occurred during the parsing of the input string.

The ValidateText method attempts to convert the formatted string contained in the Text property to an instance of the type that is specified by the ValidatingType property. Prompt characters are ignored in the formatted string, but literals are handled in accordance with the current value of the TextMaskFormat property.

ValidateText raises the TypeValidationCompleted event after the conversion is attempted, regardless of its success.

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions