Err.Raise Returns Wrong Info from OCX

We created a DCOM32.OCX.  We created a function called DCOM321.ErrorNumber as a temp for now, but we want to put the Err.Raise within it.  That way you can catch the error as a normal error at Client end.  When we try to connect to the remote server we can get server error's and then send them back to the Client EXE.  

One error being -2147221005 meaning cannot connect to server.

In the OCX we have something like this..
lr = functionname(parms)
msgbox lr            '  hr at this time is -2147221005
if hr <> 0 then
   Err.Number = lr
   Err.Raise lr + 27
   exit sub
endif

But the client EXE received -2147220978

Then we tried:

if lr <> 0 then
   lr = lr - 27
   Err.Number = lr
   Err.Raise lr + 27
   exit sub
endif

Then Client EXE received 429

The only way we can get this to work is at the client end we did this:
    msgbox Err.Description,,"Error: " & Err.Number - 27
That STINKS!

Help, on Raise, tells us to use the vbObjectError + 27 before it will work
properly.

Why must we add 27 to the ErrorObject?  
When we remove the + 27 then 429 is
sent back to the client EXE.
Because of this we can not get the error we want returned.
 
Any help would be Great!
LVL 4
ChizlAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mrmickCommented:
Chizl, your error numbers should be between 0 and 65535.  Certain error numbers are reserved by VB.  You're first example shouldn't have worked according to the docs; however,

(-2147221005) + 27 = (-2147220978)

Is a true statement.  I would assume that since errors above 65535 or below 0 are not allowed, this behavior may not be reliable.

I suspect the 429 error you experienced in your second example was a runtime error 429 (ActiveX object can't create object) because of the improper use of the ERR object.

Pick a number like 20000 for example and raise the error as follows:

Const ErrNoConnect = 20000

Err.Raise vbObjectError + ErrNoConnect

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ChizlAuthor Commented:
Thanx for the note, but that is already understood.  There is a way just maybe you and me don't know it..

-2147221005 is a Microsoft error that is returned from CLSIDFromString,
CLSIDFromProgID,
and CoCreateInstanceEx
API calls when connection to a remote server.   Using these calls disables VB debugging and we have figuared a way around it so ppl can debug again.  Miscrosoft knows of this problem and is fixed in VB6, but for now we are updating our DCOM32.ocx to return the error numbers that the API call returns to us.   http://www.karland.com/OurProducts/DCom32/ to see what we have so far.
0
ChizlAuthor Commented:
Oh, by the way as you can see we have returned -2147220978 so subtracting 27 from it should be possible.  We just didn't want the end user to have to do this.
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

ChizlAuthor Commented:
-2147221005  == "Invalid class string" in MS terms..   If you have VC5 you can go into the BIN directory and launch ErrLookup
0
mrmickCommented:
Chizl, I didn't say it couldn't be done.  I have no idea what else may be affected if you go outside of the number range reserved for VB errors.  At best, my guess is you'll get unpredictable behavior (which might explain your experience).   Search help on "raise".
0
mrmickCommented:
Chizl, I didn't say it couldn't be done.  I have no idea what else may be affected if you go outside of the number range reserved for VB errors.  At best, my guess is you'll get unpredictable behavior (which might explain your experience).   Search help on "raise".
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.