• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 166
  • Last Modified:

Errors in DLL

Hi.

'this is my Dll
Dim oTrans as New Trans

'i use his method, but ensue error
oTrans.Method

'I need know Error number of this error
MsgBox Err.Number
0
mikibenek
Asked:
mikibenek
  • 7
  • 6
  • 2
1 Solution
 
Éric MoreauSenior .Net ConsultantCommented:
What is the code in your DLL? Do you handle error in there?

Have you tried "err.Raise err.number" in your method?
0
 
josevillarCommented:
I'm not sure if I understand your problem.

You need an "On Error Goto" clause in the class method.
Once an error fires you can retrieve it in a class property named ErrNumber.

Dim oTrans as New Trans

oTrans.Method

msgbox oTrans.ErrNumber
0
 
Éric MoreauSenior .Net ConsultantCommented:
josevillar brings a good point!

Your client code must look like this:

Sub Something()
'this is my Dll
Dim oTrans as New Trans

on error goto eh

'i use his method, but ensue error
oTrans.Method

exit sub

eh:
'I need know Error number of this error
MsgBox Err.Number

End Sub
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
mikibenekAuthor Commented:
To emoreau:
I have it so, but oTrans return err.number = 0.
0
 
mikibenekAuthor Commented:
To emoreau:
I have it so, but oTrans return err.number = 0.
0
 
Éric MoreauSenior .Net ConsultantCommented:
What is the code in your Method?
0
 
mikibenekAuthor Commented:
To emoreau:
I have it so, but oTrans return err.number = 0.
0
 
mikibenekAuthor Commented:
To emoreau:
I have it so, but oTrans return err.number = 0.
0
 
mikibenekAuthor Commented:
Public Function Method(ByVal cErr As String)
    If cErr = "" Then Err.Raise 5
   
End Function
0
 
Éric MoreauSenior .Net ConsultantCommented:
Right-click in the code editor, choose toggle and choose break on unhandled errors.
0
 
josevillarCommented:
to mikibenek

If you want to raise an error you
have to add "vbObjectError" to your code

Public Function Method(ByVal cErr As string)
    If cErr = "" Then Err.Raise vbObjectError + 5
     
End Function
0
 
Éric MoreauSenior .Net ConsultantCommented:
vbObjectError has nothing to do with the fact that the error will be handled by the client app or not!
0
 
mikibenekAuthor Commented:
To emoreau:
Sorry, I know it. I solved my problem alone.
0
 
Éric MoreauSenior .Net ConsultantCommented:
By curiosity, how did you solve it?
0
 
mikibenekAuthor Commented:
Public Function Method(ByVal cErr As string)
On Error GoTo Error

  If cErr = "" Then GoTo Error
   Exit Function

Error:      
  Err.Raise vbObjectError + number
End Function
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 7
  • 6
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now