
Passing Single Data types to DLL's
Quote:
>I can pass Integer Data types, one-at-a-time and as an array, without
>problem. Thanks for that help people. Now, I'd like to pass a Single Data
>type to a DLL but keep getting the dreaded " Bad DLL Calling Convention".
>What am I doing wrong? I've declared function as:
>Declare Function rMin Lib "rMathLib.DLL" (ByVal X1 As Single, ByVal X2 As
>Single) As Single
>and I use it as:
>rMinTemp = rMin(rMinTemp, rTemp).
>As you can see, I initialize rMinTemp (Yes, I really do) to some value,
>grab a number to compare the first with, ship them over to rMin and expect
>one of the values to come back. (Yes, this is only an exercise.)
Is this your own dll or one that you got somewhere? Usually what
you do with real types is not try to pass them by value or return real values -
typically you'd pass them by reference and also pass a dummy variable by reference
for the dll to fill in with the result. You set up your dll to expect pointers
to singles (or maybe that's the default, I don't know exactly where you are), and
then you'd
Declare Function rMin Lib "rMathLib.DLL" (X1 As Single, X2 As Single,
Ans As Single) as Integer
, you dim X1, X2, and ans as Single, say
X1=2
X2=3
hmm=rMin(X1,X2,ans)
and if you got it right you'd end up with ans=2. (The returned value could be
an error code...)
--
David Ullrich
Don't you guys find it tedious typing the same thing
after your signature each time you post something?
I know I do, but when in Rome...