Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Errors in DLL

Posted on 2000-04-27
15
Medium Priority
?
163 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 6
  • 2
15 Comments
 
LVL 70

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 70

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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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 70

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
 

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 70

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 100 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 70

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 70

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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses

636 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