|
-
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
)
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
|