VB.NET

Moderators: seancampbell
Number of threads: 4020
Number of posts: 10026

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Array of Arrays with Structures Posted by wr252 on 11 May 2012 at 10:42 PM
Hi there,

This is my first time posting and I'm very nearly at my wits end with this one.

I have looked at LOT of other threads, and this one:
http://www.programmersheaven.com/mb/VBNET/408131/408131/multidimensional-array-within-a-structure/

here and on other sites as well, but nothing seems to quite resemble my own brand of monster. Could anyone spare time to take a crack at this problem with me?

Specifically, I have this structure that is made up of other structures:
 Public Structure allinfo
        Dim fields As fields
        Dim datalines As loaded
        Dim peakend As Integer

    End Structure 


That part works well, but I really need to be able to load a number into a specific place in the array of arrays:

Dim report()() As allinfo

'some other code

report(peaknumber)(0).peakend = i  

'i is just a tracking integer


I would like to be able to do something like the above, but that gives the error "object reference not set to an instance of
the object." I can't declare my array as a New, that just gives the same problem:

Dim report()() As allinfo = New allinfo(maxpeaks)() {} 


To make matters worse, this gives back a nasty casting error, and I believe is returning NULLS etc. Also, it generates a 250k wide matrix!

Dim report(maxpeaks,maxpeaks) As allinfo



Please help!
Thanks
Report
Re: Array of Arrays with Structures Posted by Ian_B on 13 Jun 2012 at 9:14 AM
First off, that's not how you declare multi-dimensional arrays in VB, try:
Dim report(,) As allinfo ' you don't need NEW for an array

Then you need to define how big you want it, e.g.
Redim report(10,2)

You should then be Ok

Report
Re: Array of Arrays with Structures Posted by Ian_B on 13 Jun 2012 at 9:16 AM
First off, that's not how you declare multi-dimensional arrays in VB, try:
Dim report(,) As allinfo ' you don't need NEW for an array

Then you need to define how big you want it, e.g.
Redim report(10,2)

You should then be Ok




 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.