BUG: Err.Raise 40040 Stores the Err.Number as 440

SYMPTOMS
When the statement Err.Raise 40040 is executed, the value of Err.Number is set to 440.

RESOLUTION
Do not use the user defined error 40040.

STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION
If you raise the error code 40040 (=&H9C68) using the Err.Raise method, Visual Basic sets the value of Err.Number to 440. The Err.Description and other properties of the Err object are set correctly.

Steps to Reproduce Behavior
1. Create a Visual Basic Standard EXE project. Form1 is created by default.
2. Paste the following code in the General Declarations section of Form1:
VB Code:
  1. Private Sub Form_Load()
  2.    On Error Resume Next
  3.    Err.Raise 40040
  4.    MsgBox Err.Number & ": " & Err.Description ' will display 440
  5.    Err.Clear ' Clear the error for the next Raise method
  6.    Err.Raise 440
  7.    MsgBox Err.Number & ": " & Err.Description
  8. End Sub
3. Run the program. A message box with the error number and description raised for 40040 will be displayed.
4. Click OK and a message box with the error number and description raised for 440 will be displayed.

APPLIES TO
• Microsoft Visual Basic 5.0 Learning Edition
• Microsoft Visual Basic 6.0 Learning Edition
• Microsoft Visual Basic 5.0 Professional Edition
• Microsoft Visual Basic 6.0 Professional Edition
• Microsoft Visual Basic 5.0 Enterprise Edition
• Microsoft Visual Basic 6.0 Enterprise Edition

Keywords: kbbug KB216547

URL: http://support.microsoft.com/default...b;en-us;216547