473,394 Members | 1,737 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

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

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
1 1388
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: matt melton | last post by:
Hi there, I am trying to write a method that accepts an array of any primitive type and will return the same array without copying memory as an array of bytes. ie. I'd like to be able to do...
3
by: ABC | last post by:
I am not a javascript guru or anything so I was wondering if someone could tell me what the code below is doing. Is it creating a multidimensional array? Would it be better to create an object? ...
33
by: Peter Seaman | last post by:
I understand that structures are value types and arrays and classes are reference types. But what about arrays as members of structures i.e. as in C struct x { int n; int a; }
2
by: Andrew Burlak | last post by:
Hi, Although Unsized Arrays inside structures is a non-standard feature, I like to use it :-) It seems that Unsized Arrays are broken when /Og (Global Optimization) is enabled. The problem...
1
by: Raj | last post by:
Hi, This is regarding using Arrays of UDT's in COM. The following is a short description: - We basically need a structure, struct MAIN_STRUCT which must contain a dynamic array of another...
39
by: Martin Jørgensen | last post by:
Hi, I'm relatively new with C-programming and even though I've read about pointers and arrays many times, it's a topic that is a little confusing to me - at least at this moment: ---- 1)...
10
by: David Fort | last post by:
Hi, I'm upgrading a VB6 app to VB.net and I'm having a problem with a call to a function provided in a DLL. The function takes the address of a structure which it will fill in with values. I...
41
by: Rene Nyffenegger | last post by:
Hello everyone. I am not fluent in JavaScript, so I might overlook the obvious. But in all other programming languages that I know and that have associative arrays, or hashes, the elements in...
0
by: Art Cummings | last post by:
Good morning all. I just finished an assignment using structures. In this assignment I used an array of structures. What I would have liked was to use an array of structures with a function. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.