Solved

Errors in DLL

Posted on 2000-04-27
15
153 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
consolidate or create a new vba code for performing tasks 5 62
passing a value with stream reader AFTER a ";" 3 58
Spell Check in VB6 13 95
Added a column screws up code 5 47
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
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.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

929 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

9 Experts available now in Live!

Get 1:1 Help Now