Sams Teach Yourself Visual Basic 6 in 24 Hours

Sams Teach Yourself Visual Basic 6 in 24 Hours

By Greg Perry

Text Boxes

Text boxes accept user input. Although several other controls accept user input, text boxes are perhaps the easiest to set up and respond to. In addition, a text box is easy for your users to use, and they see text boxes on Windows forms all the time.

Figure 4.7 shows a running application with two text boxes that accept user input.

04fig07.gif

Figure 4.7 Two text boxes request user information.

Table 4.3 lists the common properties associated with text boxes. By familiarizing yourself with the properties now, you will be able to produce applications more quickly as you learn more about Visual Basic.

Table 4.3. Common text box properties.

Property Description
Alignment Determines whether the text box's text appears left-justified, centered, or right-justified within the text box's boundaries.
BackColor Specifies the text box's background color. Click the BackColor property's palette down arrow to see a list of colors and click System to see a list of common Windows control colors.
BorderStyle Determines whether a single-line border appears around the text box.
Enabled Determines whether the text box is active. Often, you'll change the Enabled property at runtime with code when a text box is no longer needed.
Font Produces a Font dialog box in which you can set the Text property's font name, style, and size.
ForeColor Holds the color of the text box's text.
Height Holds the height of the text box's outline in twips.
Left Holds the number of twips from the text box's left edge to the Form window's left edge.
Locked Determines whether the user can edit the text inside the text box.
MaxLength Specifies the number of characters the user can type into the text box.
MousePointer Determines the shape of the mouse cursor when the user moves the mouse over the text box.
MultiLine Lets the text box hold multiple lines of text or sets the text box to hold only a single line of text. Add scrollbars if you want to put text in a multiline text box so your users can scroll through the text.
PasswordChar Determines the character that appears in the text box when the user enters a password, which keeps prying eyes from knowing what the user enters into a text box.
ScrollBars Determines whether scrollbars appear on the edges of a multiline text box.
TabIndex Specifies the order of the text box in the focus order.
TabStop Determines whether the text box can receive the focus.
Text Holds the value of the text inside the text box. The Text property changes at runtime as the user types text into the text box. If you set an initial Text property value, that value becomes the default value that appears in the text box when the user first sees the text box.
ToolTipText Holds the text that appears as a ToolTip at runtime.
Top Holds the number of twips from the text box's top edge to the Form window's top edge.
Visible Determines whether the text box appears or is hidden from the user.
Width Holds the width of the text box in twips.

Share ThisShare This

Informit Network