PRB: "On Error Resume Next" Statement Causes Loss of Extra Error Information
ID: Q208613
|
The information in this article applies to:
-
Microsoft Windows CE Toolkit for Visual Basic 6.0, version 1.0
SYMPTOMS
The On Error Resume Next statement causes loss of extra error message information such as err.description for undefined variables. This could be important because undefined variables are not caught at compile time when Option Explicit is enabled.
STATUS
This behavior is by design.
MORE INFORMATION
Steps to Reproduce Behavior
- Start a new Windows CE HPC Project in Visual Basic.
- Add two command buttons to Form1.
- Paste the following code into Form1:
Option Explicit
Private Sub Command1_Click()
'On Error Resume Next
BigError = "This is a big error!"
End Sub
Private Sub Command2_Click()
MsgBox Err.Number & " " & Err.Description
End Sub
- Run the project in emulation or in the remote device.
- Click on Command1 and the following message appears:
Application Error:
An error was encountered while running this program:
Variable is undefined: 'BigError'
- Click on Command2 and the following message = appears:
500 Variable is undefined: 'BigError'
- Stop the project from executing and uncomment the On Error Resume Next statement in the Command1_Click event.
- Run the project again.
- Click on Command1 and note that the application error does not occur anymore. This is expected.
- Click on Command2 and the following error message appears:
"500 Variable is undefined".
Note that the error description information has been lost.
Additional query words:
Keywords : kbToolkit kbVBp600 kbWinCE kbGrpVB
Version : WINDOWS:1.0
Platform : WINDOWS
Issue type : kbprb