Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Array of Arrays with Structures

wr252wr252 Posts: 1Member
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:
[link]http://www.programmersheaven.com/mb/VBNET/408131/408131/multidimensional-array-within-a-structure/[/link]

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:
[code]
Public Structure allinfo
Dim fields As fields
Dim datalines As loaded
Dim peakend As Integer

End Structure
[/code]

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

[code]
Dim report()() As allinfo

'some other code

report(peaknumber)(0).peakend = i

'i is just a tracking integer
[/code]

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:

[code]
Dim report()() As allinfo = New allinfo(maxpeaks)() {}
[/code]

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!

[code]
Dim report(maxpeaks,maxpeaks) As allinfo
[/code]


Please help!
Thanks

Comments

  • Ian_BIan_B Posts: 2Member
    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

  • Ian_BIan_B Posts: 2Member
    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

Sign In or Register to comment.