Page 287 - Excel Progamming Weekend Crash Course
P. 287
n540629 ch20.qxd 9/2/03 9:35 AM Page 262
262 Saturday Evening
Figure 20-3 Using the RefEdit control to select a range
The TextBox Control
The TextBox control is one of the most useful controls available to the Excel programmer.
It can display text to the user for editing and can also be displayed as blank to permit the
user to enter data.
With its default settings, a TextBox control displays a single line of text. If the text it
contains is too wide for the size of the control, it scrolls out of view off to the right. The
user can move around in a text box with the usual text-editing keys (including the arrow
and End and Home keys). This is the case even if the text box’s height is sufficient to dis-
play multiple lines of text.
If you want to display more than one line of text in a TextBox control, set its MultiLine
property to True. The user can then start a new line of text by pressing Shift+Enter (or just
Enter, depending on the setting of the EnterKeyBehavior property as explained in Table
20-4). Also, text automatically wraps to a new line when it reaches the right edge of the
text box. If you do not want text to wrap, so that new lines start only when the user
presses Shift+Enter, set the control’s WordWrap property to False.
If a multiline TextBox control contains more lines of text than can be displayed, the
extra lines scroll out of view at the top and/or bottom of the text box. You can display
scroll bars in a text box, permitting scrolling vertically and horizontally to bring text into
view. This is done by setting the ScrollBars property to one of the following values:
fmScrollBarsNone (the default)
fmScrollBarsHorizontal
fmScrollBarsVertical
fmScrollBarsBoth
Table 20-4 describes some other properties of the TextBox control.