Tech News

Creating a Program in the Visual Basic Integrated Development Environment

Program Development and Debugging

Programming errors happen. Any program of any significant size or complexity will certainly have at least one error in it. The process of locating and fixing these errors is called debugging. Since debugging is such an important (and frequent) part of the application development process, Visual Basic includes special tools to aid in locating and correcting problems.

Error Types

There are three types of programming errors: syntax errors, runtime errors, and logic errors. Syntax is the set of rules that must be followed when language statements are written. Syntax errors occur when program statements do not follow these rules. Misspelling a Visual Basic keyword is an example of a syntax error.

The final type of error is the logic error. All statements in the program are syntactically correct and the program encounters no runtime errors, but the results are not as expected.

Visual Basic Debugging Tools

One of the most useful Visual Basic debugging tools is the breakpoint. A breakpoint is a marker placed in the program. The program will temporarily stop running when a breakpoint is encountered. This allows the programmer to use other debugging tools to obtain information about the program while it is paused in midexecution. To set a breakpoint, first place the cursor on the desired program statement. Press F9 or click in the gray margin to the left of the statement. The statement will be highlighted, usually in red, and a large dot will appear in the grey margin to the left of the line.

. At execution, the program pauses before executing this statement. The Visual Basic environment is now in Break mode. The statement at which the program paused is highlighted and a yellow arrow appears on the dot in the gray margin. To continue executing the program, click on the Run symbol in the Standard toolbar. The program will continue to execute until it reaches another breakpoint or runs to completion. Breakpoints are removed by clicking the dot in the gray margin to the left of the statement.

At execution, the program pauses before executing this statement. The Visual Basic environment is now in Break mode. The statement at which the program paused is highlighted and a yellow arrow appears on the dot in the gray margin. To continue executing the program, click on the Run symbol in the Standard toolbar. The program will continue to execute until it reaches another breakpoint or runs to completion. Breakpoints are removed by clicking the dot in the gray margin to the left of the statement.

Last word

The debugging tools available in Visual Basic are most effective when used in combination. Watch windows and Data Tips windows allow the programmer to see what is happening “inside” the program as it runs. This information can help identify instructions that are not producing expected results. Single Stepping through a program also allows the programmer to see exactly which statements are executing and in what order. This can help identify problems in modules, loops, and decision structures.

Related Articles

Leave a Reply

Your email address will not be published.

Back to top button