Visual Basic: RichTextBox Control

MaxLength Property (RichTextBox Control)

See Also    Example    Applies To

Returns or sets a value indicating whether there is a maximum number of characters a RichTextBox control can hold and, if so, specifies the maximum number of characters.

Syntax

object**.MaxLength** [**=**long]

The MaxLength property syntax has these parts:

Part Description
object An object expression that evaluates to a RichTextBox control.
long A long integer specifying the maximum number of characters a user can enter in the control. The default for the MaxLength property is 0, indicating no maximum other than that created by memory constraints on the user's system. Any number greater than 0 indicates the maximum number of characters.

Remarks

Use the MaxLength property to limit the number of characters a user can enter in a RichTextBox.

If text that exceeds the MaxLength property setting is assigned to a RichTextBox from code, no error occurs; however, only the maximum number of characters is assigned to the Text property, and extra characters are truncated. Changing this property doesn't affect the current contents of a RichTextBox,****but will affect any subsequent changes to the contents.