Solved

Errors in DLL

Posted on 2000-04-27
15
152 Views
Last Modified: 2010-05-02
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
Comment
Question by:mikibenek
  • 7
  • 6
  • 2
15 Comments
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 2754895
What is the code in your DLL? Do you handle error in there?

Have you tried "err.Raise err.number" in your method?
0
 

Expert Comment

by:josevillar
ID: 2754914
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
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 2754937
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
 

Author Comment

by:mikibenek
ID: 2754958
To emoreau:
I have it so, but oTrans return err.number = 0.
0
 

Author Comment

by:mikibenek
ID: 2754968
To emoreau:
I have it so, but oTrans return err.number = 0.
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 2754973
What is the code in your Method?
0
 

Author Comment

by:mikibenek
ID: 2754976
To emoreau:
I have it so, but oTrans return err.number = 0.
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 

Author Comment

by:mikibenek
ID: 2755005
To emoreau:
I have it so, but oTrans return err.number = 0.
0
 

Author Comment

by:mikibenek
ID: 2755007
Public Function Method(ByVal cErr As String)
    If cErr = "" Then Err.Raise 5
   
End Function
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 2755081
Right-click in the code editor, choose toggle and choose break on unhandled errors.
0
 

Accepted Solution

by:
josevillar earned 50 total points
ID: 2755125
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
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 2755202
vbObjectError has nothing to do with the fact that the error will be handled by the client app or not!
0
 

Author Comment

by:mikibenek
ID: 2755225
To emoreau:
Sorry, I know it. I solved my problem alone.
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 2755244
By curiosity, how did you solve it?
0
 

Author Comment

by:mikibenek
ID: 2755268
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now