|
-
May 1st, 2008, 09:09 AM
#1
Thread Starter
PowerPoster
divide by 0 error when calling VC++ dll from VB6
This is very strange to me, and I wonder if someone can tell me whats wrong and how to fix this:
When I call a VC++ dll from VB6 the call is executed without error. However, any subsequent attempt to access a variable that was passed into and out of the dll results in a "runtime error 11 divide by zero". When I debug to the error, the error has vanished and I can access the variable fine (albeit err.number is still > 1, but the statement will execute. The statement that causes the error 11 is as simple as:
myDbl = opt
when in debug mode, just after the dll call I can hover over the passed value and see "opt=<division by zero". Then when I execute "myDBl = opt" it raises the error, but now I can hover over opt and see that it has a value and the statement will now execute.
I could, of course do some tricks with loops and "on error resume next", but this would be bad practice and inefficient (speed is extremly critical), so I really want to understand the problem and fix it properly instead of tricks or workarounds.
I have all of the source code for the dll.
Any ideas?
Code:
declaration:
Private Declare Function Sol Lib "si.dll" ( ...
call:
ret = Sol(m, 14, obj, func(0), cons(0), valu(0), typ(0), opt, res(0))
dll structure:
short _stdcall si( short num_variables,
short num_co,
short ob,
double* function_co,
double* con_co,
double* con_val,
short* con_ine,
double* op_val,
double* op_var_val
)
-
May 1st, 2008, 04:15 PM
#2
Re: divide by 0 error when calling VC++ dll from VB6
How are you returning it out of the DLL? Chances are, you're returning a NULL pointer.. which, will be 0.
chem
Visual Studio 6, Visual Studio.NET 2005, MASM
-
May 1st, 2008, 04:40 PM
#3
Thread Starter
PowerPoster
Re: divide by 0 error when calling VC++ dll from VB6
Thanks for the reply.
One of our guys just got it fixed. The stated reason for the behavior was that the value considered infinity was set too low and any division result over that value was considered divide by zero . Seems to be working now.
-
Oct 11th, 2010, 07:56 AM
#4
New Member
Re: divide by 0 error when calling VC++ dll from VB6
I am also facing similar problem.
Any idea how you got it fixed?
Is there a way of setting Infinity in VBA?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|