ID Number: Q74906
1.00
WINDOWS
Summary:
Using the carriage return character, Chr$(13), alone to create a line
wrap to the next line in a Visual Basic text box control will cause
the character following the carriage return to be removed from a
multiline text box. To correctly wrap to the next line, you must
instead use both a carriage return and a linefeed, Chr$(10). This
requirement is by design.
This information applies to Microsoft Visual Basic programming system
version 1.0 for Windows.
More Information:
The correct method to create a line wrap is to use a carriage return
character followed by a linefeed character, Chr$(13) + Chr$(10). The
Windows text box expects to find this sequence and assumes that the
character following the carriage return is a linefeed, thus removing
the following character as if it were a linefeed.
The following steps show the results of using just the carriage
return, and the results of using both carriage return and linefeed
characters in a text box.
1. In a new project, click on the text box icon from the Toolbox
(second tool down in the right column).
2. Click anywhere on the form and drag diagonally to create a text box
large enough to hold more then one line of text.
3. From the Properties bar (below the main menu) scroll down to
Multiline, then choose the Settings box for that Multiline property
(also on the Properties bar below the menu) and choose True. The
text box can now accommodate several lines of text.
4. Double-click anywhere in the form outside of the text box to bring
up the Form_click code window (or use the F7 function key).
5. On the line below Sub Form_click (), type the following:
Text1.text = "Hello" + Chr$(13) + "World"
6. Press F5 to run the newly created application, then click
anywhere in the form outside the text box. The following text
will appear:
Hello
orld
Note that the W of "World" is missing.
7. To obtain the desired result, you must add a linefeed following the
carriage return character, as follows:
Text1.text = "Hello" + Chr$(13) + Chr$ (10) + "World"
This will now display as expected:
Hello
World
Additional reference words: 1.00