|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Err ObjectHi guyz
I wonder whether it's better to raise an error with a custom error number or set the err.number to that custom error number and then raise error I mean: 1 - Err.Number = 123456 Err.Raise Err.Number 2 - Err.Raise 123456 well which one is better and why? thanx alot Err.Raise <number> is the correct way. This sets Err.Number for you
I wouldn't recommend modifying any of the Err properties manually -- use Err.Raise to set them, and Err.Clear to clear them down. You may notice that Err.LastDllError is read-only anyway. Also, on your Err.raise statement, you must set a 'source' and 'description' for user-defined errors, otherwise you'll incur an 'Automation error' or 'Application-defined Error', e.g. Err.Raise 11 ' OK since using the pre-defined code for "Division by zero" 'Using a user-defined error code Const lErrCode As Long = vbObjectError OR 1000 Err.Raise lErrCode , "MyClass", "MyErrorMessage" Tony Proctor Show quoteHide quote "Jefe" <J***@discussions.microsoft.com> wrote in message news:8DCC2C1F-4AD2-4EBA-A88A-C3325EA5203A@microsoft.com... > Hi guyz > I wonder whether it's better to raise an error with a custom error number or > set the err.number to that custom error number and then raise error I mean: > 1 - Err.Number = 123456 > Err.Raise Err.Number > 2 - Err.Raise 123456 > well which one is better and why? > thanx alot well why you wouldn't recommend modifying Err properties manually?
Show quoteHide quote "Tony Proctor" wrote: > Err.Raise <number> is the correct way. This sets Err.Number for you > > I wouldn't recommend modifying any of the Err properties manually -- use > Err.Raise to set them, and Err.Clear to clear them down. You may notice that > Err.LastDllError is read-only anyway. > > Also, on your Err.raise statement, you must set a 'source' and 'description' > for user-defined errors, otherwise you'll incur an 'Automation error' or > 'Application-defined Error', e.g. > > Err.Raise 11 ' OK since using the pre-defined code > for "Division by zero" > > 'Using a user-defined error code > Const lErrCode As Long = vbObjectError OR 1000 > Err.Raise lErrCode , "MyClass", "MyErrorMessage" > > > Tony Proctor > > "Jefe" <J***@discussions.microsoft.com> wrote in message > news:8DCC2C1F-4AD2-4EBA-A88A-C3325EA5203A@microsoft.com... > > Hi guyz > > I wonder whether it's better to raise an error with a custom error number > or > > set the err.number to that custom error number and then raise error I > mean: > > 1 - Err.Number = 123456 > > Err.Raise Err.Number > > 2 - Err.Raise 123456 > > well which one is better and why? > > thanx alot > > > Because it's unnecessary, and misleading. Poking an error code into
Err.Number doesn't imply that an error has been raised anywhere Tony Proctor Show quoteHide quote "Jefe" <J***@discussions.microsoft.com> wrote in message news:24B54C8C-2BDA-46D3-9346-FFFD5FF8A633@microsoft.com... > well why you wouldn't recommend modifying Err properties manually? > > "Tony Proctor" wrote: > > > Err.Raise <number> is the correct way. This sets Err.Number for you > > > > I wouldn't recommend modifying any of the Err properties manually -- use > > Err.Raise to set them, and Err.Clear to clear them down. You may notice that > > Err.LastDllError is read-only anyway. > > > > Also, on your Err.raise statement, you must set a 'source' and 'description' > > for user-defined errors, otherwise you'll incur an 'Automation error' or > > 'Application-defined Error', e.g. > > > > Err.Raise 11 ' OK since using the pre-defined code > > for "Division by zero" > > > > 'Using a user-defined error code > > Const lErrCode As Long = vbObjectError OR 1000 > > Err.Raise lErrCode , "MyClass", "MyErrorMessage" > > > > > > Tony Proctor > > > > "Jefe" <J***@discussions.microsoft.com> wrote in message > > news:8DCC2C1F-4AD2-4EBA-A88A-C3325EA5203A@microsoft.com... > > > Hi guyz > > > I wonder whether it's better to raise an error with a custom error number > > or > > > set the err.number to that custom error number and then raise error I > > mean: > > > 1 - Err.Number = 123456 > > > Err.Raise Err.Number > > > 2 - Err.Raise 123456 > > > well which one is better and why? > > > thanx alot > > > > > >
Other interesting topics
Creating a DLL and calling it from an app
How to calculate this? Sudden automation error with MS XML object Runtime error 53 memory leak ? Recent File Parse and preserve an object in a class SP5 to SP6: To update or not? How do I deploy a VB6 program to folder whose filename has spaces? App Protection |
|||||||||||||||||||||||