Page 288 - Excel Progamming Weekend Crash Course
P. 288
n540629 ch20.qxd 9/2/03 9:35 AM Page 263
Session 20 — Controls for User Forms 263
Table 20-4 Some Properties of the TextBox Control
Property Description
EnterKeyBehavior If False (the default), pressing Enter moves the focus to the next
control and the user must press Shift+Enter to start a new line in
the text box. If True, pressing Enter starts a new line.
MaxLength The maximum number of characters that the text box can hold.
If 0 (the default), there is no limit.
PasswordChar Specifies the placeholder character used to display text in the text
box. For example, set this property to “*” to display all asterisks.
Used for password entry to prevent accidental viewing of the pass-
word by an unauthorized person. The default blank setting displays
all characters as themselves.
TabKeyBehavior If True, pressing Tab inserts a tab into the text (but only if the
MutliLine property is also True). If False (the default), pressing
Tab moves the focus to the next control.
TextLength Returns the number of characters in the text box
To retrieve or set the data in a TextBox control, use either its Text or Value property.
These two properties are exactly equivalent, with the older Text property being retained for
compatibility with earlier versions of Excel.
Turn to Session 22 for an example of using the TextBox control.
Cross-Ref
The ToggleButton Control
The ToggleButton control is used to select and display True/False values. Functionally it is
essentially identical to the CheckBox control but displays its state as either up or down (for
False and True, respectively). The control’s Value property returns True or False depending
on its state. Changing the Value property changes the control’s appearance.
REVIEW
This session covered the controls that are available for user forms in Excel programs.
There are 15 different controls available.
The Enabled property determines whether a control can be modified by the user.
The Visible property determines if a control is shown on the form.
The TextBox control is used for the display and entry of text data.