Pass Array handel in UDT to DLL

I have a function in a c++ dll that gets a pointer to double array. inside a struct.
I defined a UDT in VB5 and passed all the rest of the UDT fields fine, the problem is with this array.
type Type1
  par1 as Integer
  myArr as double
end type
dim myType as Type1 , arr() as double
ReDim arr(1000)

I don't know how to set myType.myArr to point to arr


if I pass the array seperetly it's easy and it works but I need it in the UDT.
CALL dllfunction(myType,arr(0))

Is this posible???
HELP
Shai
shaiiAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

corvanderlindenCommented:
Try this:

type Type1
  par1 as Integer
  myArr() as double
end type
dim myType as Type1

ReDim myArr(1000)

0
shaiiAuthor Commented:
I have tried this before and now again.
but it doesn't seem to work.

I'll make it clear.
In the dll the struct is waiting for a pointer to a double array

if it wasn't inside a struct I would
have passed arr(0) to the function
but it is!!!
HELP
0
corvanderlindenCommented:
I do not know the C code but one thing is important

In VB an integer is 2 bytes
In C it is 4

Try
type Type1
  par1 as long
  myArr() as double
end type
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

mcriderCommented:
Have you read these microsoft KB articles:

HOWTO: Fill a 32-bit VBA Array of UDType via a Visual C++ DLL
http://support.microsoft.com/support/kb/articles/Q171/5/83.ASP 
 
HOWTO: Pass Array of UDTs with Variable Length Strings to C/C++
http://support.microsoft.com/support/kb/articles/Q194/6/09.ASP 
 


Cheers!

0
shaiiAuthor Commented:
corvander...
  the problem is with passing the double array not with the int
(I know I should pass it as long it was only for an example, my UDT is much bigger)

mcrider:
I have checked these sites but they are concerning passing arrays of UDT's.
while I have and UDT and a pointer to an array inside it I need to pass!

HELP!!!
0
thomasschaeferCommented:
Hi,

well you only need the pointer to arr().
I am not very familiar with c but in ASM i would do it like this.
Write a c-function in your dll that returns the array-pointer. and make the type like this.

type Type1
  par1 as Integer
  myArr as LONG    ---> not double
end type

dim myType as Type1 , arr() as double
ReDim arr(1000)

mytype.myarr=dllretpointer(arr(0))

now it should be easy to access the array from your dll.

Thomas

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
shaiiAuthor Commented:
I have solved the problem.
Using VarPtr(arr(0))
it returns a pointer to the array.

10x any way.
Shai
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.