
Question: Catching errors from a VB ActiveX control in Visual C++ using MFC
I am not sure what you mean by using Try and Catch in VB, it does not use
those as keywords. So far as catching you can implement it kind of. Using
your example
Function SomeFunction() as Boolean
On Error Goto Catch
SomeFunction = True
....Some Code
Err.Description = "Device not Found on " & m_Port
Err.Raise vbObjectError + 7
SomeFunction = False
Exit Function
Catch:
...Error Handling Routine For above Function Here
End Function
Hope this helps you......
Quote:
>G'day peoples. I'm using an ActiveX control written in VB from a MFC
>application (using VC 5.0). The documentation I have for the control says
>that it uses "standard VB error handling techniques". The problem is that
>the handling of any errors I'm getting doesn't suit my purposes and I'd
>like to be able to catch it and handle it differently. The problem is, I
>don't know how to catch "Standard VB errors". I've done some fiddling with
>try and catch but the error seems to avoid my catch statement and ends up
>at a lower level.
>Could some suggest how I could catch this error? The VB code being used to
>raise the error is using the err object. One such line is like this:
> Err.Description = "Device not Found on " & m_Port
> Err.Raise vbObjectError + 7
>Any hints on how to catch this from VC++ would be much appreciated.
>Thanks,
>Ian Rowlands
>(remove the .nospam off the e-mail address if replying by mail)