Solved

Errors in DLL

Posted on 2000-04-27
15
159 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
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 

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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…

724 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