473,654 Members | 3,068 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(dimensi on)
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 1401
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.c o.uk> wrote in message
news:02******** *************** *********@4ax.c om:
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(dimensi on)
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
13915
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 something like: char chars = "Hello!"; byte bytes = (byte) chars;
3
1974
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? function addKey(commentKey, codeHexa, gotoPage, funcToLoad) { aKey = new Array(); aKey = commentKey; aKey = codeHexa;
33
3855
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
1822
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 occurs whenever the unsized array is declared as 'const'. Here is an example:
1
2521
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 struct, struct SUB_STRUCT. We have a interface function that is callable by the client, which takes a dynamic array of MAIN_STRUCT as parameter. So the problem is wrt passing around dynamic
39
19617
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) What's the difference between these 3 statements: (i) memcpy(&b, &KoefD, n); // this works somewhere in my code
10
4984
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 get an error: ---------------- An unhandled exception of type 'System.NullReferenceException' occured in
41
4925
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 the hash are alphabetically sorted if the key happens to be alpha numeric. Which I believe makes sense because it allows for fast lookup of a key.
0
1356
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. The problem I ran into, was when the i tried to read the data in the structure I got garbage. Normally when I use arrays they retain the information that I enter once the function completes. I'm thinking that it has something to do with using the...
0
8285
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8814
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8706
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8591
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7304
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6160
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5621
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4293
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1592
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.