See Also Example
Determines whether there is a limit to the length of the Text The default for the MaxLength property is 0, indicating no maximum other than that created by memory constraints on the user's system for single line text boxes, and a maximum of about 32K for multiline text boxes. Any number larger than 0 indicates the maximum number of characters. property.
[form.]textbox.MaxLength[ = numericexpression ]
Use the MaxLength property to limit the number of characters a user can enter into a text box.
If text longer than MaxLength is assigned to a text box 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 text box but will affect any subsequent changes to the contents.
MaxLength Property Example
The example uses a numerical value in one text box to limit the length of text in the other text box. To try this example, paste the code into the Declarations section of a form that contains two text boxes. Make Text1 fairly large. Then press F5. Enter a number into Text2 and other text into Text1.
Sub Text1_Change ()
Text1.MaxLength = Text2.Text