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
Solved

Errors in DLL

Posted on 2000-04-27
15
155 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 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…
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…

809 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