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
Running Applications
You learned in Hour 1, "Visual Basic at Work," that you can execute a Visual Basic application by running the application or by first compiling the application and then running the executable compiled program. For the majority of your VB training, you'll run applications from within the Visual Basic development environment without taking the time to compile the application first. Usually, compilation is the last step a programmer takes before distributing the application to other users.
Generally, and for all of this tutorial, you'll run your applications from within the Visual Basic development environment. When you run within the development environment, you gain all kinds of advantages that your users will not need. You can stop the program in midstream and analyze values (using the debugging tools available in the development environment), you can start and stop your program at any point, you gain access to the source code faster each time you stop the program, and the program's startup is faster than having to wait for the compiler. See Hour 20, "Writing Correct Applications," for additional information about debugging your applications.
Although several ways exist to run the program, the easiest is to press F5, the accelerator key for the Run | Start menu option. (A Start toolbar button also gives you quick access to the application's startup.)
Press F5 now to run the application. The application contains fields where you enter investment values. Enter an interest rate, term, and investment amount. Click the Compute Interest button to see an ending investment value such as the one in Figure 2.3. If you change a value, click the Compute Interest button once again to see how the change affects the investment. Click Exit to close the running program.
Figure 2.3 Running the application.
Click a button once to see that button's properties in the Properties window. Figure 2.4 shows the properties for the Compute Interest button. Each control supports a unique set of properties to differentiate the control from surrounding ones. For example, the Compute Interest button is named cmdCompute and has a Caption property value of &Compute Interest (the ampersand indicates an underlined letter) but the Exit button is named cmdExit and has a Caption property of E&xit. Although many of the two buttons' properties are identical, they contain differences that set them apart, as you see when you scroll through the Properties window.
Figure 2.4 The cmdCompute button's properties.
Where's the Code? | Next Section

Account Sign In
View your cart