You are on page 1of 7

Visual Basic 6

CHAPTER-1 Contents
Starting Out with Visual Basic
1. 2. 3. 4. What is a Computer Program?. Computer Programs and Programming Languages. Visual Basic Is a Smart Language. How Design Fits into the Programming Process

Microsofts Visual Basic product is defined as a programming system. Simply put this programming system is used to write Windows-based computer programs; it includes the Visual Basic language as well as a number of tools that help you write these programs.

What Is a Computer Program?


With Visual Basic, you can design programs, also known as applications, to accomplish just about any task you can imagine. Computer programs generally fall into two very broad categories: - packaged and custom. Packaged programs are those that you can purchase in a software store, via mail order, direct from a manufacturer, and so on. Packaged programs are predesigned to accomplish some specific task. For example, you may purchase Microsoft Word to meet your word processing needs, Symantecs WinFax Pro to enable your computer to send and receive faxes, or McAfees Virus Scan to help prevent viruses from attacking your system. Custom programs are usually designed for a specific purpose within a particular organization. For example, a company may need an application that tracks product orders from the time they are placed until they are actually shipped.

Computer Programs and Programming Languages


A computer program is nothing more than a set of instructions that a computer follows to accomplish a specific task. A programming language such as Visual Basic is used to translate instructions as we humans understand them into the steps that the computer can comprehend and follow.

Visual Basic is a Smart Language


The main reason why Visual Basic is so popular and powerful is the same reason behind the success of Windows. Microsoft took a complex technology (writing computer programs) and made it easier to use through a graphical interface. Suppose you have to write a program for your company. In a visual programming environment, you can quickly design the windows that the user sees by drawing and arranging them just as you would lay out elements for a newspaper. In a text-based programming system, you control the user interface through program language commands. Common sense tells you that the visual programming method is easier for newcomers to learn and requires less time to maintain. Another key concept of Visual Basic is the ability to create and use self-contained components, or objects. One type of object that you learn about very shortly is a Visual Basic control. Controls are elements you can use when designing a user interface, just like the real-life controls on a car dashboard. These controls can be used to display information (like a speedometer) or take action (like the ignition switch). The underlying operations of the car, such as the relationship between ignition, starter, and engine, are hidden from the driver; he communicates with the car through a clearly defined interface. In the same way, Visual Basic controls enable you to add features to your programs without you having to be involved in the details of how these features work. For example, receiving input from a user of your program is as simple as drawing a control that accepts input. This is a great advantage of visual programming languages - you can concentrate on what you want your program to do, not how to get the programming language to do it.

How Design Fits into the Programming Process


When creating a computer program, its important to take a structured approach. Certain steps need to be accomplished in a certain order, and you might as well get used to doing things the right way. Its always tempting to fire up Visual Basic and dive right in to designing and coding the program, but a little time spent with proper planning can save you a lot of headaches later in the process.

The key steps in creating a computer program are as follows: 1. Plan the programs tasks (how it should work). 2. Design the user interface (how it should look). 3. Write the programs code (implement steps 1 and 2). 4. Test and debug the program (including beta testing with users outside of the development team, if appropriate). 5. Document and distribute the program (put it in use).

Program Design
The design process should produce the following results: A concise list of tasks to be performed by the program. Deadlines for when particular tasks need to be completed. Clarification of the dependence of one part of the program on another. The criteria for testing the program.

CHAPTER-2 Contents
Creating Your First Program
1. 2. 3. 4. 5. Creating Your Programs User Interface Getting Information From the User Changing a Forms Properties Coding Your Programs Actions Running Your Program

Creating Your Programs User Interface


A programs user interface refers to the part(s) of the program that the user sees and interacts with. As you develop this applications interface, youll see how to use some of the many tools provided in Visual Basics Integrated Development Environment (IDE). In this chapter, youll create a Loan Calculator program that calculates the periodic payment needed to repay a loan, based on various factors such as the loan term and interest rate. Your users will be able to input and modify values for these and other variable factors, perform the calculation, and view the results. In addition, they will be able to view an amortization schedule for the entire life of the loan. Fig1 C:2 shows the Loan Calculators main screen as its being used.

Getting Started
Lets begin by creating a new project. A project is simply a set of files that store information about the components that make up an application (program). To create a Visual Basic program, you customize your projects various components. To get started with the Loan Calculator program, start Visual Basic; you will see the New Project dialog box shown in Fig2 C:2. If Visual basic is already running, or if you dont see the New Project dialog, choose File, New Project (see Fig3 C:2.).

Fig1 C:2

Fig2 C:2

Fig3 C:2

Fig4 C:2

The New Project dialog box enables you to specify the type of project you want to create. For the Loan Calculator project, select the Standard EXE option and click OK. You will then be placed in Visual Basics design environment, as illustrated in Fig4 C:2. First off, notice Visual Basics title bar - specifically, the word design. This means that you are in Design mode, also known as design time, a name for the time you spend designing your program. Later, when you run your program, Visual Basic will be in Run mode. As you see, a new Standard EXE project consists of one form, or window, which will usually be your programs main user interface. Visual Basic applications are comprised of one or more components, such as forms, code modules and classes, along with controls and other components.

Fig5 C:2

Look at the Project Explorer (illustrated in Fig5 C:2). It consists of a list of the contents of the current project. Because youve just begun this project, it only contains a single form named Form1, which is located in the Forms folder of the project (named Project1 by default). A project can grow to include many components; the Project Explorer helps keep them organized. To save a project, choose File, Save Project from the Visual Basic menu system, or simply click the Save Project button on the toolbar. The first time you save the project, (or after you subsequently add any files to the project) youll be led through one or more of the Save File As dialog boxes (see Fig6 C:2), one for each of the project components, and then a Save Project As dialog box for the project file. You specify the name and location of each file where the components (and project) are to be saved. Subsequent Save Project operations simply resave the components using the same filenames as before. Then you can easily execute frequent, quick saves of a previously saved project by clicking the Save Project button. If one or more components have been added to the project since it was last saved, the Save File As dialog box will be presented for each new component.

You might also like