Sams Teach Yourself Visual Basic 6 in 24 Hours
- Table of Contents
- Copyright
- About the Author
- Acknowledgments
- Introduction
- Who Should Read This Book
- What This Book Will Do for You
- Can This Book Really Teach Visual Basic in 24 Hours?
- What You Need
- Files on the Visual Basic Distribution CD-ROM
- Conventions Used in This Book
- Enough! Time Is Ticking!
- Part I: Introducing Visual Basic
- Hour 1. Visual Basic at Work
- Hour 2.Analyzing Visual Basic Programs
- Hour 3.Controls and Properties
- Hour 4.Examining Labels, Buttons, and Text Boxes
- Part II: Coding the Details
- Hour 5.Putting Code into Visual Basic
- Hour 6.Message and Input Boxes
- Hour 7.Making Decisions
- Hour 8.Visual Basic Looping
- Part III:Putting Code to Work
- Hour 9.Combining Code and Controls
- Hour 10.List Boxes and Data Lists
- Hour 11.Additional Controls
- Hour 12.Dialog Box Basics
- Part IV:Programming with Data
- Hour 13.Modular Programming
- Hour 14.Built-In Functions Save Time
- Hour 15.Visual Basic Database Basics
- Hour 16.Printing with Visual Basic
- Part V:Sprucing Up Programs
- Hour 17.Menus and Visual Basic
- Hour 18.The Graphic Image Controls
- Hour 19.Toolbars and More Graphics
- Hour 20.Writing Correct Applications
- Part VI:Advancing Visual Basic Applications
- Hour 21.Visual Basic and ActiveX
- Hour 22.Object Basics
- Hour 23.Distributing Your Applications
- Hour 24.Online Visual Basic
- Part VII:Appendixes
- Appendix A.Operator Precedence
- Appendix B.Answers
- Appendix C.Using the CD-ROM
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.
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. |
Form Properties | Next Section

Account Sign In
View your cart