
VB5: Passing Arrays to a DLL and back
Quote:
> Under Visual Basic 5 (learning edition) how can I pass an array of
> integers (either entered or predefined) to a VC++ DLL and have the DLL
> say add 1 to each digiit and return the modified array to VB to be
> displayed on screen. I can do this with simple single integers or
> doubles or longs etc. but cannot get this to work for a single
> dimensional array of elements. If you can help please e-mail.
Ok
The DLL only needs to receive the address of the FIRST element of an
array.
So if you have an array of "MyArray(10) of Double" in the calling
program and the data type used to manipulate the array in the DLL was
the same then it only needs to be called like this:
Call MyDllFunction (myarray(0))
and the declaration for this DLL function in VB would be similar to
this.
Declare Sub MyDllFunction Lib "MyDllFile" (ByRef AnArray as Double)
Because arrays are stored contiguously (did i spell that right) in
visual basic the DLL only needs to know where the array starts (the
first element).
Peter Brooks