Declaring structure arrays

J

John Dann

Is there a way of declaring an array of a structure where the
structure has a constructor? So if I had a structure say

Friend MyStructure
prop1 as integer
prop2 as string
sub New (p1 as integer, p2 as string)
me.prop1=p1
me.prop2=p2
End Sub
End Structure

' If I was declaring a single variable I could say:
Dim MyVar as MyStructure(100, text)

' But I can't think how to do this if I wanted:
dim MyVar(50) as MyStructure...

Is this possible/impossible?

Thanks
JGD
 
J

Josip Habjan

Hi,

It is impossible.
But you can do Dim MyVar(50) as MyStructure and then loop thru array and
then set MyVar(index) = new MyStructure(100, text)

Regards,
Josip Habjan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top