|
-
February 25th, 2000, 01:41 AM
#1
Calling C from VB
Hi,
I am trying to call a C/C++ function contained in a DLL. Most of the required C parameters are vectors and matrices. I have tried many alternatives, but when I debug the DLL the VB arrays are not getting passed through to C.
This is not an issue (as far as I know) of decorated names or mangling, the DLL and its exported function is located OK.
I have defined the VB side as " ... ByRef myArray() as double", and the C side as "double *myArray".
If anyone knows how to overcome this it would be much appreciated.
Thanks.
-
February 25th, 2000, 04:14 AM
#2
Re: Calling C from VB
I seem to remember somewhere in the VB documentation that you should always pass in the first element of your array to the C DLL.
eg.
lRet = MyCFunction(sSomeArray(0), lSomeOtherValue)
- make sure you know where your arrays start from though!
Chris Eastwood
CodeGuru - the website for developers
http://codeguru.developer.com/vb
-
February 25th, 2000, 06:34 AM
#3
Re: Calling C from VB
Declare the function like this for double * myArray
Declare Function SomeCFunc(byref lpAr as Double)
and use it like this
dim someAr(100) as Double
SomeCFunc(somear(0)) ' technically
' *myarray is nothing but &myarray(0), right?
You can also try As Any, but it is not necessary because you are not passing a structure.
RK
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
|