Click to See Complete Forum and Search --> : Passing an array to a DLL procedure


hitesh_kapadia
August 25th, 2001, 07:25 AM
Hello,

I am creating a DLL object in which I am creating a function which does some manipulation on the array passed to it. I am calling the function from another VB EXE project. The type of the array in the calling file is Variant(). When the function is called, it is giving an error 'Type Mismatch'. How do pass an array to the function? Please help me.

Thanks in advance
Hitesh

berta
August 26th, 2001, 08:04 AM
do U try in this way?

dim myobj as new mylib.myclass

dim myarray(10) as variant
'also U can declare dim myarray(10)

'possible code for filling or initializing myarray

myobj.method_with_array(myarray)

hi,brt


<center>
<HR width=80%>
<img src='http://web.tiscali.it/bertaplanet/images/bertaplanet.gif'>
</center>

hitesh_kapadia
August 26th, 2001, 10:55 PM
Hello,

The size of the array is not fixed. It is derived at the runtime. In such a case how do I define the array?

Thanks
Hitesh

berta
August 27th, 2001, 02:23 AM
dim my_array() 'define an empy array

redim my_array(10) 'define a new dimension for array with lost of data.

redim preserve my_array(10) 'define a new dimension for array without lost of data (this method is very heavy)

hi,brt

<center>
<HR width=80%>
<img src='http://web.tiscali.it/bertaplanet/images/bertaplanet.gif'>
</center>

Cakkie
August 27th, 2001, 03:43 AM
Try passing the first element of the array only. This should pass a refference to the array. I know this is how you must pass an array to a C++ function.

If that doesn't help, there's something else worth trying. Variants and objects can be arrays themselves. So try passing it as a variant or object rather than an array
Of course, make sure that the function being called accepts the appropriate datatype.

Dim myarray(10) as variant
dim myvar as variant

' pass first element
Call SomeFunction(myArray(0))

' Pass an array
myvar = myArray
Call SomeFunction(myvar)

' pass an object
set myObject = myvarray
Call SomeFunction(myObject)




Tom Cannaerts
slisse@planetinternet.be

Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook