Article ID: 195631
Article Last Modified on 5/12/2003
APPLIES TO
- Microsoft Visual Basic 6.0 Learning Edition
- Microsoft Visual Basic 5.0 Learning Edition
- Microsoft Visual Basic 6.0 Professional Edition
- Microsoft Visual Basic 5.0 Professional Edition
- Microsoft Visual Basic 6.0 Enterprise Edition
- Microsoft Visual Basic 5.0 Enterprise Edition
- Microsoft Visual Basic 5.0 Control Creation Edition
This article was previously published under Q195631
SYMPTOMS
The value of the "Alignment" property of a TextBox control is ignored and the default of "left aligned" is applied on some systems. The same application installed on other systems does not exhibit this behavior.
CAUSE
Visual Basic derives its TextBox control from a proprietary class called "ThunderTextBox," which in turn is based on the "Edit" class provided by the operating system. Because the operating system defines the "Edit" class, some of the properties and functionality of a TextBox may change depending upon the version of the operating system where the application is executed. This is the case with the TextBox's Alignment property. In earlier versions of Windows, changes to the "Alignment" property would not take effect unless the "MultiLine" property of the TextBox was set to "True." The latest versions of the Windows operating system no longer have this limitation.
Any control from any development environment that is derived from the "Edit" class will demonstrate the same change in behavior.
Versions of Windows that require the "MultiLine" property to be set to "True" in order for the "Alignment" property to take effect include:
Windows 95 (regardless of service packs)
Windows NT 3.51 (regardless of service packs)
Windows NT 4.0
Windows NT 4.0 with Service Packs 1 or 2
Versions of Windows that do not have this requirement include:
Windows 98
Windows Me
Windows NT 4.0 with Service Pack 3 or higher
RESOLUTION
There are two approaches for working around this inconsistency:
- Assume the older operating system limitation is being enforced and set the TextBox control's "MultiLine" property to "True."
- Use multiple overlapping TextBox controls and vary which one is visible depending on the operating system in use (checked via API) and the alignment desired.
STATUS
This behavior is by design.
REFERENCES
For additional information, please see the following articles in the Microsoft Knowledge Base:
189249 HOWTO: Determine Which 32-Bit Windows Version Is Being Used
111952 HOWTO: Right Justify/Center Text in Single-Line Text Control
Keywords: kbprb kbeditctrl KB195631