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
Option Buttons
Figure 11.1 shows an application with four option buttons. An option button gives your user a choice. By clicking the option button or by sending the focus to the option button and pressing the Spacebar to choose the option, the user selects or deselects an option button. When selected, the option button has a black center inside its circle.
Figure 11.1 A form with four option buttons.
Option buttons act in a mutually exclusive fashion. Only one option button can be selected at any one time. Therefore, in Figure 11.1, the user could not select two or more of the options. If the user were to click Texas, the California option would no longer be selected. You don't have to do anything special to ensure that only one option button is selected at any one time; Visual Basic takes care of removing the former option's selection when the user selects a subsequent option button.
The option button supports several of the properties you're already familiar with, such as the Appearance and Alignment properties. The Alignment property determines whether the option button text resides to the left or right of the option button. Figure 11.2 shows the option buttons with their Alignment property set to 2-Right Justify. The alignment you set depends on where the option buttons are to fall in relation to other controls.
Figure 11.2 These option buttons have a right-justified Alignment property.
The Value property is perhaps the most important option button property because the Value property changes at runtime and determines whether the option button is currently selected. By the way, the user can select only one option button at a time, but the application may start up without any option buttons being set if you don't set any in the Properties window or in code.
Frames and Option Buttons | Next Section

Account Sign In
View your cart