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
Generating an Application from Scratch
Enough already! How about a little fun? You can create your very first Visual Basic application without knowing any more than you know now about Visual Basic. The secret is Visual Basic's VB Application Wizard, a wizard that generates an application for you based on your responses to a series of dialog boxes.
A skeleton program is a program shell that you must fill in with specific code.
Despite the ease with which you can generate an application shell with the VB Application Wizard, this book doesn't revisit the wizard after this section. You need to get well grounded in Visual Basic before you'll really understand how to add to the generated program and change the shell to suit your needs. Therefore, the VB Application Wizard arguably benefits the experienced Visual Basic programmer more than the beginning programmer because the experienced programmer will be able to decipher the generated shell and add specifics to make the program operate as needed.
Perform these steps to generate your first Visual Basic application with the VB Application Wizard:
- Select File | New Project. Click No at the dialog box that asks if you want to save any changes to the Interest Calculation application because you don't want to overwrite any changes you might have made.
- When the New Project dialog box appears, double-click the VB Application Wizard icon to start the wizard.
- Read through the wizard's dialog boxes and click Next when you're ready to move to the next dialog box. Keep all the default values along the way. As you'll see on the Menus dialog box (shown in Figure 2.6), the wizard gives you a choice of menu items you want to see on the generated application's menu bar. Although menus are relatively simple to place in a Visual Basic application, the wizard makes placing menus much simpler because you only need to check the boxes next to the items you want on the final application's menu bar.
Figure 2.6 Selecting the menu items you want to place in the final application.
- As you click through the wizard, look for the dialog box that describes the application's Internet connectivity. The generated application, despite being a shell, can access the Web directly. You can send your application's users to a Web page or let them view Web pages from inside your own application. The real magic is that the wizard handles all the details for you if you want the options. For now, don't select Internet Access but keep moving through the dialog boxes by clicking Next.
- The wizard gives you a chance to interface with a database program, such as Microsoft Access, before taking you to the final dialog box, where you click Finish to watch Visual Basic's wizard perform its wizardry. Right before your eyes, the wizard will put the application together, add the forms, and build the menus.
- Click the closing dialog box and close the final instructions. The wizard leaves your development environment fairly clean, but you know that you can double-click any object in the Project window to see forms and code modules. For now, simply run the program to see Figure 2.7's screen.
Figure 2.7 The VB Application Wizard generated a working, albeit plain, application.
The generated program looks somewhat like a word processor because of the large editing area in the center of the screen. Try the menus and click the toolbar buttons. Things look good. You will find that the application doesn't respond to your keystrokes as you might expect, however. If you attempt to perform certain tasks, a small dialog box will appear telling you that what you requested has not yet been implemented by the programmer (you).
You must remember that it's not the wizard's job to generate a fully working application that performs specific tasks. The wizard's job is to construct a general application to which you can later add the specifics. As you learn more about Visual Basic, you will better appreciate how much time and effort the VB Application Wizard saves you because the simple task of adding a standard menu and toolbar buttons can take an afternoon. The generated application is a great starting point for your own applications once you and Visual Basic become better acquainted.
Summary | Next Section

Account Sign In
View your cart