6.1 Overview when creating each process, it should be assumed that it may have an error (1) Error Source: programmer environment (Disk Space) time (not loaded) (2) Error classification: 1. Compile For example: PublicsubMyProcedure (intMyVariableAsInteger) Call: CallMyProcedure (invVariable1,
6.1 Overview when creating each process, it should be assumed that it may have an error (1) Error Source: programmer environment (Disk Space) time (not loaded) (2) Error classification: 1. Compile For example: Define: Public sub MyProcedure (intMyVariable As Integer) Call: CallMyProcedure (invVariable1,
6.1 Overview
When creating each process, it should be assumed that it may have an error
(1) Error Source:
Programmer
Environment (disk space)
Time (not loaded)
(2) Error classification:
1. Compile
For example:
Definition: Public sub MyProcedure (intMyVariable As Integer)
Call: Call MyProcedure (invVariable1, intVariable2)
2. runtime:
The result of an attempt to perform an invalid operation on the variable.
Print 10/intMyVariable
(3) Objective: To create an error handling program to prevent program running from being interrupted.
Visual Basic compilation options
(1) One configuration item is "Compile On Demand)
Start/F5 and compile only the Code required to run the application
Compile hidden errors when removing requests:
Disable "compile upon request" and run it. Force VB to check the entire application to find out the compilation error.
Generate executable files for the project. Force VB to check the entire application to find out the compilation error.
Run -- full compilation and execution; press Ctrl + F5
(2) One configuration item is Background Compile)
Compilation of processes and modules when referenced; compilation of unreferenced modules at leisure, with compilation errors kept at the lowest level
6.2 Err Object
The Raise method of the Err Object will cause an error and form the attributes of the Err Object.
6.3 error handling program type
After an error is captured, the error message is not displayed, and the code is not terminated.
Capture errors
OnError statement, located in the first line, placed immediately behind the process title and before the variable description.
Two methods:
OnError GoTo, which is transferred to the specified code for execution.
The OnError Resume Next statement ignores code errors and skips execution.
A runtime error, for example:
Test the Err Object at any time, for example:
Uppercase letters should be used for all annotations.
To ensure that the error handler is executed only when an error occurs, add the ExitSub, Exit Function, or Exit Property statement before the error handler.