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

  1. Start a new Windows CE HPC Project in Visual Basic.


  2. Add two command buttons to Form1.


  3. Paste the following code into Form1:


  4. 
    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 
  5. Run the project in emulation or in the remote device.


  6. Click on Command1 and the following message appears:


  7. 
    Application Error:
    An error was encountered while running this program:
    Variable is undefined: 'BigError' 
  8. Click on Command2 and the following message = appears:


  9. 
    500 Variable is undefined: 'BigError' 
  10. Stop the project from executing and uncomment the On Error Resume Next statement in the Command1_Click event.


  11. Run the project again.


  12. Click on Command1 and note that the application error does not occur anymore. This is expected.


  13. Click on Command2 and the following error message appears:


  14. 
    "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


Last Reviewed: September 1, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.