Sams Teach Yourself Visual Basic 6 in 24 Hours

Sams Teach Yourself Visual Basic 6 in 24 Hours

By Greg Perry

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.

02fig03.gif

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.

02fig04.jpg

Figure 2.4 The cmdCompute button's properties.

Share ThisShare This

Informit Network