?
Solved

VBA::_ErrObject

Posted on 2004-04-29
4
Medium Priority
?
769 Views
Last Modified: 2007-12-19
Hello.

I've got such a problem. In Visual Basic I have made ActiveX Dll and function like:

Public Sub showError(error as ErrObject)
...
End sub

A this Dll I want to use in VC++
I create IDL file, compile it, generated .c and .h files were added to project a compiled.

But then the function in VC++ looks like:
HRESULT showError(VBA::_ErrObject **error);

And I don't know how to create that VBA::_ErrObject in VC++.
It look like it is a normal COM object (_ErrObject) but _ErrObjectPtr.CreateInstance doesn't work.

I have #import msvbvm60.dll used.

Thanks for help.

0
Comment
Question by:hanzelko
  • 2
  • 2
4 Comments
 
LVL 9

Expert Comment

by:_ys_
ID: 10948680
Within VB ErrObject is non-creatable. It's static. Try making:
Set objError = New ErrObject
work.

Expose a GetErrObject from your VB ActiveX DLL and use it to obtain a pointer to ErrObject from VC++. At least you'll get an ErrObject pointer which you can pass to showError.
0
 

Author Comment

by:hanzelko
ID: 10958419
Hi.

I have tried it.
But Set objError = new ErrObject doesn't work.
It throws exception ActiveX cant create object in VB.

So I have used
Set objError = err     // return global error object.

This works, but behaves buggy. Something in objErrr is set when I call showError but description is not set.
It looks like the objError is the same global err object and objErr.descritption is empty.

So where can be problem.
0
 
LVL 9

Accepted Solution

by:
_ys_ earned 500 total points
ID: 10959215
> But Set objError = new ErrObject doesn't work.
I'd already suggested it wouldn't. My comment was ambiguous.

> It looks like the objError is the same global err object
It is. Atfer all it is global static declared.

There's special restrictions put on the VB ErrObject - a discussion of which is better suited to the VB area. VB does reset this at regular intervals, so you cannot wholly guarantee it's contents from one function to function.

If you truly want to persist it's value, and govern its contents, I suggest you roll out your own pseudo-ErrObject. I've had to do this before within VB itself, never mind interoperating with C++, so I know it's a pain in the ar$e.
0
 

Author Comment

by:hanzelko
ID: 10959443
Ok thanks a lot. I have though about it the same way. pseudoErrObject will be good.
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

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

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

569 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