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
Where's the Code?
This lesson began by describing code and event procedures in detail, and yet not a word has been mentioned about those topics for several pages. The code is there as a module file, as you can see from the Project Explorer window. Actually, the interest calculation program contains two sets of code.
Controls cannot have the same name if you place them on the same form, but two forms might contain controls with the same name. A control name goes with its parent form. For example, an application might contain an About dialog box and a form that displays account information. Both forms can have a command button named cmdExit that closes the form's window. Each form contains its own code, called the form module, that manages and responds to the controls on that form. You won't always put code in a form's form module, but you often will.
The Project window's Modules entry also is a file with code in it. A module file that lies outside a form module is often called a standard module. You'll place event procedures for forms in the forms' form modules and you'll place common routines that work on all the forms in a standard module file that lies outside the form module but still in the project.
You enter, edit, and view the language of VB in the Code window.
Visual Basic always presents you with VB code in the Code window. A Code window acts a lot like a simple text editor or word processor, in that you can insert, delete, copy, cut, and paste text. Despite the graphical nature of applications and the controls, the code you write to tie things together is still in text.
Take a brief look at the application's single module's Code window by double-clicking the Project window's Module1 entry. Visual Basic opens the module's Code window, as shown in Figure 2.5.
Figure 2.5 The module's Code window.
Code appears in the Code window in various colors to indicate the purpose of the code. As you learn the Visual Basic language, you will better understand why some code is green and some black. Scroll down through the Code window. Don't worry about understanding much or anything about the Code window at this time. As you can see, much of the Code window contains words in English, but the structure might seem completely odd if you've never programmed before. By the time you finish this 24-hour tutorial, you will understand the entire program and be able to speak the Code window's language fluently.
Click Close to close the module's Code window (not VB!) for now. When you close the Code window, make sure that you see the Interest form before you start the next section. If you don't see the Interest form, simply double-click the frmInterest form in the Project window.
Event Procedures | Next Section

Account Sign In
View your cart