Linker IT Software
Google
Web www.oraxcel.com
menubar-top-links menubar-top-rechts
Home Help Search Login
Welcome, Guest. Please Login.
SQL*XL: Database to Excel bridge litLIB: Excel power functions pack ExcelLock: Locking and securing your valuable Excel spreadsheets encOffice: Protect your Excel file easy and safe encOffice: Protect your Excel file easy and safe
Pages: 1
VB6: Err.Number from Err.Raise in Class_Initialize (Read 6053 times)
Gerrit-Jan Linker
YaBB Administrator
*****




Posts: 75
VB6: Err.Number from Err.Raise in Class_Initialize
17.11.07 at 21:43:02
 
VB6: Err.Number from Err.Raise in Class_Initialize
 
I noticed that when raising errors in a Class_Initialize in Visual Basic 6 (VB6) that the error number raised is always 440 instead of the error number raised. Beware!
 
I use the following technique to catch and reraise errors. This is much like it works in Oracle PL/SQL using exception clauses.
 
Sub MySub()
  On Error Goto ErrorHandler
 
  'Some statements
  Exit Sub
ErrorHandler:
  'An error occurred. Handle it here or raise it again to handle it higher in the call stack
  Err.Raise err.number, App.Title, "Custom error message"
End Sub
 
Each calling routine in the call stack can reraise the error using:
 
If Err.Source = App.Title and Err.Number > vbObjectError then
  Err.Raise Err.Number
end if
 
This works very fine however I just noted that when one raises an error in an Class_Initialize the err.number is always populated with 440.
Back to top
 
 

Gerrit-Jan Linker
Linker IT Software
Email WWW Gerrit-Jan Linker   IP Logged
Pages: 1