473,513 Members | 2,618 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Use of the number of ErrObject in VB6 through a dll made in VB .NE

Hi,

I try to use the ErrObject in one of my class Library. The class Library is
written in VB .NET and the dll should be used in a VB6 application or a VB
..NET application.

Here is a simple example of the code I wrote in .NET:

Public Class Class1
Public Sub test()
Err.Raise(777,,"test description", "test help link")
End Sub

Public Sub test2()
Err.Raise(888,,"test description2", "test help link2")
End Sub

Public Sub test3()
Err.Raise(999)
End Sub
End Class

And now here is my problem.

When I catch the error in .NET (using On Error), I have access to the
description and to the help file link. But, no matter what error number I
use, the program written in VB 6 always has the same error number.

This number is: -2146233088.

After googling it, I found a post which says that this is a COM error
exception: "managed code casting unhandled exception".

So, my question is: How do I use the number attribute of the ErrObject ?

Remark: when I use the Dll in VB .NET, I catch the correct number.

Thanks in advance for any help or any pointer.

For the record, here is a sample of a VB 6 code that I use to catch the error:

Private Sub Form_Load()
On Error GoTo there
MsgBox ("test")
Dim tst As ErrorVB6.Class1
Set tst = New Class1
tst.Test
there:
MsgBox (Err.Number & ":" & Err.Description & "-" & Err.HelpFile)
End Sub

Mar 29 '06 #1
2 1876
can anybody help please ?

"Slimane" wrote:
Hi,

I try to use the ErrObject in one of my class Library. The class Library is
written in VB .NET and the dll should be used in a VB6 application or a VB
.NET application.

Here is a simple example of the code I wrote in .NET:

Public Class Class1
Public Sub test()
Err.Raise(777,,"test description", "test help link")
End Sub

Public Sub test2()
Err.Raise(888,,"test description2", "test help link2")
End Sub

Public Sub test3()
Err.Raise(999)
End Sub
End Class

And now here is my problem.

When I catch the error in .NET (using On Error), I have access to the
description and to the help file link. But, no matter what error number I
use, the program written in VB 6 always has the same error number.

This number is: -2146233088.

After googling it, I found a post which says that this is a COM error
exception: "managed code casting unhandled exception".

So, my question is: How do I use the number attribute of the ErrObject ?

Remark: when I use the Dll in VB .NET, I catch the correct number.

Thanks in advance for any help or any pointer.

For the record, here is a sample of a VB 6 code that I use to catch the error:

Private Sub Form_Load()
On Error GoTo there
MsgBox ("test")
Dim tst As ErrorVB6.Class1
Set tst = New Class1
tst.Test
there:
MsgBox (Err.Number & ":" & Err.Description & "-" & Err.HelpFile)
End Sub

Apr 4 '06 #2
you sure that you're not having an err.number = 0 problem?

Private Sub Form_Load()
On Error GoTo there
MsgBox ("test")
Dim tst As ErrorVB6.Class1
Set tst = New Class1
tst.Test
cleanexit:
exit sub
there:
MsgBox (Err.Number & ":" & Err.Description & "-" & Err.HelpFile)
End Sub

i wish i could be more help; i'm way over my head on .net error handling

Apr 5 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
12013
by: EAS | last post by:
Hey, I'm new to python (and programming in general) so I'll prolly be around here a lot... Anyways, I've found out how to make a "guess my number game" where the player guesses a number between...
33
25617
by: Steven Bethard | last post by:
Is there a good way to determine if an object is a numeric type? Generally, I avoid type-checks in favor of try/except blocks, but I'm not sure what to do in this case: def f(i): ... if x < i:...
12
2899
by: jose luis fernandez diaz | last post by:
Hi, My OS is: cronos:jdiaz:tmp>uname -a HP-UX cronos B.11.11 U 9000/800 820960681 unlimited-user license I compile in 64-bits mode the program below:
4
2381
by: Wahoo | last post by:
Another question,my teacher gave me a code for generate a random number from 1 - range, but I can't made it work, where is the problem? Thanks!!
1
2565
by: bclists | last post by:
Can anybody provide the code needed to pass the error object to a function or subroutine. TIA.
5
2351
by: Shane | last post by:
I wonder if someone has any ideas about the following. I am currently producing some reports for a manufacturing company who work with metal. A finished part can contain multiple sub-parts to...
122
5202
by: Einar | last post by:
Hi, I wonder if there is a nice bit twiddling hack to compare a large number of variables? If you first store them in an array, you can do: for (i = 0; i < n; i++) { if (array != value) {...
4
6981
by: Jonathan | last post by:
Hi, I have a listview with many rows init. The first column is "No." which shows the row number in the listview. When a user selected a row and delete it, say row 3. I want to organise the...
19
4412
by: gk245 | last post by:
Trying to write a program that will figure out if a number is perfect or not. Here is my logic: 1) Read in the number 2) Split it up (number - 1) 3) Put all the split up numbers into an...
0
7257
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7379
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
5682
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5084
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4745
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3232
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3221
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
455
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.