Microsoft KB Archive/285932

= BUG: MaxLength Property Is Ignored When Alignment Property Is Changed =

Article ID: 285932

Article Last Modified on 10/15/2002

-

APPLIES TO


 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition

-



This article was previously published under Q285932



SYMPTOMS
When the MaxLength property of a TextBox control is set at design time, and the Alignment property of the control is changed at run time, the MaxLength value is ignored.



RESOLUTION
To work around this problem, reset and assign the MaxLength property at run time. See the code sample in the &quot;More Information&quot; section.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce Behavior
 Create a new standard EXE project in Visual Basic. Form1 is created by default. Add a TextBox control to Form1. Set the MaxLength property of the TextBox control to 1.  Paste the following code into the code window of Form1: Private Sub Form_Load Text1.Text = &quot;&quot; Text1.Alignment = 1 ' To work around this bug, uncomment the following two lines of code. '   Text1.MaxLength = 0 '   Text1.MaxLength = 1 End Sub  Press the F5 key to run the program. Type multiple characters in the TextBox control, and notice that the MaxLength property is ignored.</li></ol>

NOTE: This bug does not occur in Visual Basic 5.0 because the Alignment property is read-only at run time.

Additional query words: left right center justify

Keywords: kbbug kbctrl kbpending KB285932

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.