By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,839 Members | 2,270 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,839 IT Pros & Developers. It's quick & easy.

Arrays of structures that contain an array - is it even possible??

P: n/a
Is it possible in VB.net to have arrays of structures (ie UDTs) where
the structure definition includes one or more arrays? Something like:

Structure MyUDT
ItemOne () as byte 'for example
sub new(byval dimension as integer)
redim itemone(dimension)
end sub
End structure

dim MyArray as myudt = new myudt(n)
' where n is known
'This works, but

dim Myarray() as myudt = new myudt(n)

gives a design-time error even before redimming the array.

I've got 3 options:

1. I can no longer have this sort of UDT array in VB.net (I'm sure I
used to have something similar working in VB6).

2. It is possible but needs a different syntax/declaration.

3. It is possible and the syntax above ought to work, but I've made a
mistake in my own code (the real UDT is much more complicated than the
example above and includes several such arrays in the UDT definition.
Though I've checked it's still possible that there might be a
typing/coding error).

Any help with this would be much appreciated - it's a key part of a
current project.

John Dann
Nov 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi,

The problem with code is that you want to create an unknown amount of
myudt. If you donít know the size of myarray why donít you look into
storing myudt in an Arraylist or collection.

Ken
==========

"John Dann" <ne**@prodata.co.uk> wrote in message
news:02********************************@4ax.com:
Is it possible in VB.net to have arrays of structures (ie UDTs) where
the structure definition includes one or more arrays? Something like:

Structure MyUDT
ItemOne () as byte 'for example
sub new(byval dimension as integer)
redim itemone(dimension)
end sub
End structure

dim MyArray as myudt = new myudt(n)
' where n is known
'This works, but

dim Myarray() as myudt = new myudt(n)

gives a design-time error even before redimming the array.

I've got 3 options:

1. I can no longer have this sort of UDT array in VB.net (I'm sure I
used to have something similar working in VB6).

2. It is possible but needs a different syntax/declaration.

3. It is possible and the syntax above ought to work, but I've made a
mistake in my own code (the real UDT is much more complicated than the
example above and includes several such arrays in the UDT definition.
Though I've checked it's still possible that there might be a
typing/coding error).

Any help with this would be much appreciated - it's a key part of a
current project.

John Dann


--
Outgoing mail is certified Virus Free.
Checked by AVG Anti-Virus (http://www.grisoft.com).
Version: 7.0.230 / Virus Database: 263.3.9 - Release Date: 7/2/2004
Nov 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.