Working wih redimensioned array with User defined type

The Actual problem in all this was the redim preseve in the DLL does not work properly .

1. I define an User define type in Dll
and an array of the user defined type

Public type udt
  t1 as s tring
  I1 as integer
end type
Private myarr() as udt

2. the function in Dll component does some thing like this

Public function X() as boolean

for i = 1 to 50
   Redim Preserve myarr(i)
   '****** this statemenmt causes the
   '****  general protection fault

   myarr(i).t1 = "test" & i
   myarr(i).I1 = i

next i
end function

** this function is directly accessed from a standard project which has forms

3. The same procedure works well in the devlopment environment but fails when u actually make the dll and refrence it from the project..

4. The question arises how do you work with redimentioning array's having structures i mean user defined type in it. The whole exercise  is actually for populating a tree structure using a binary tree algorithm . Well this works fine when you dimension it at the begining ( ie; if it is a fixed type of array)

ie; dim myarr(1000) as udt

Any help in this reagard is apprciated ..

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.

Try this:

ReDim myarr(0) as as udt
for i = 1 to 50
   Redim Preserve myarr(i) as udt
   myarr(i).t1 = "test" & i
   myarr(i).I1 = i

next i


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
jaggi06Author Commented:
Yes I missed that and tried to redimension and preserve the array with value

ie; redim preserve myarr(0)

Thank you for exactly pinning at the right point ..

Thanks for the points! Glad I could help!

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.