|
-
August 25th, 2001, 07:25 AM
#1
Passing an array to a DLL procedure
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
-
August 26th, 2001, 08:04 AM
#2
Re: Passing an array to a DLL procedure
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/im...ertaplanet.gif'>
</center>
-
August 26th, 2001, 10:55 PM
#3
Re: Passing an array to a DLL procedure
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
-
August 27th, 2001, 02:23 AM
#4
Re: Passing an array to a DLL procedure
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/im...ertaplanet.gif'>
</center>
-
August 27th, 2001, 03:43 AM
#5
Re: Passing an array to a DLL procedure
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
[email protected]
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
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
|