• No matter how hard we try, errors do creep into our programs. These errors
can be grouped into three categories:
-
Syntax errors
-
Run-time errors
-
Logic errors
• Syntax errors occur when you mistype a command or leave out an expected
phrase or argument. Visual
Basic detects these errors as they occur and even provides help in correcting
them. You cannot run a Visual
Basic program until all syntax errors have been corrected.
• Run-time errors are usually beyond your program's control. Examples include:
when a variable takes on an unexpected value (divide by zero), when a drive door
is left open, or when a file is not found. Visual Basic allows you to trap such
errors and make attempts to correct them.
• Logic errors are the most difficult to find. With logic errors, the program
will usually run, but will produce incorrect or unexpected results. The Visual
Basic debugger is an aid in detecting logic errors.
• Some ways to minimize errors:
-
Design your application carefully. More design time means less
debugging time.
-
Use comments where applicable to help you remember what you were trying to
do.
-
Use consistent and meaningful naming conventions for your variables, objects,
and procedures.
Tutorial
Main Page | Previous Page | Contents
| Next Page