Microsoft Office Tutorials and References
In Depth Information
Tip A Push of a Button
Use the command button when you want to call a subroutine to process the information on
the form.
The TextBox Control
The Te xtBox control is the primary control that’s used to accept text from the user. Text boxes
come in two main flavors: single-line and multi-line . This is controlled by the Multiline prop­
erty. When Multiline is Tr ue , the control will display multiple lines of text in the box;
otherwise, the text box will display only a single line of text.
Tip Taking a Break
You can force the text to start on a new line by embedding the constant vbCrLf (carriage-
return, line-feed) before the first character of the next line. This white space can be helpful
if you wish to break a long block of text into paragraphs.
If you have more text than can be displayed in either a single-line or multi-line text box, you
have the option to include scroll bars so that the user can scroll to see the hidden text. You can
set the ScrollBars property to fmScrollBarsHorizontal to display a scroll bar on a single-line text
box, or you can set the ScrollBars property to fmScrollBarsHorizontal , fmScrollBarsVertical , or
fmScrollBarsBoth to display a horizontal or vertical scroll bar, or both in a multi-line text box.
Set this property to fmScrollBarsNone for either type of text box if you don’t want to display
any scroll bars.
Another useful property for multi-line text boxes is the Wo rdWrap property. When Wo rdWrap
is set to Tr ue , any lines that are too long to be completely displayed in the horizontal space
available will be wrapped to the next line on a word boundary so as not to split a word
between lines. However, in this case, you will not be able to display a horizontal scroll bar.
The LineCount property returns the number of lines in a multi-line text box.
The characters displayed in a text box control are available in both the Te xt and Va flue prop­
erties, and you can change what is displayed in the text box by changing either property.
However, it’s customary to use the Te xt property instead of the Va flue property. The Change
event will be fired if a value is assigned to either property.
Note The Change event is fired for each character entered by a user into the text box.
This event can be used to validate the information entered into the text box one character
at a time. However, if you wish to validate the entire text box after the user has finished
entering data, use the Exit event (which is fired automatically when the focus leaves the
text box) instead of the Change event.
Search JabSto ::




Custom Search