Steve
Steve

Reputation: 579

VB.Net Multidimensional Arrary

Trying to populate a multidimensional array, but not having much luck, although I think I am close!

Although there could be one or many rows, the dimensions will be static (3). Right now I am just trying to populate one row in the array and three columns. Not all of the code is included, I am hoping to be concise.

Right now only the last element is retained, FileName, so the array only equals FileName, when it should be populated as: FileName, PageCount, FileSize.

Any pointers would be welcomed, thank you!

    Dim ImgData(,,) As String
    '
    '
    '
    ReDim Preserve ImgData(0, 0, 0)

    For intCol1 = 0 To ImgData.GetUpperBound(0)
        For intCol2 = 0 To ImgData.GetUpperBound(0)
            For intCol3 = 0 To ImgData.GetUpperBound(0)
                ImgData(0, 0, intCol3) = FileSize
            Next intCol3
            ImgData(0, intCol2, 0) = PageCount
        Next intCol2
        ImgData(intCol1, 0, 0) = FileName
    Next intCol1

Upvotes: 0

Views: 168

Answers (1)

Victor Zakharov
Victor Zakharov

Reputation: 26454

I think you are confusing tuples and multi-dimensional arrays. But because I never recommend tuples, consider using a custom class instead. Then you storage pattern will become a list of custom class objects, each with 3 properties, FileSize, PageCount and FileName.

To get more understanding of what a multi-dimensional array is, see here:

And here is how it looks (so that's probably not what you wanted):

enter image description here

Upvotes: 2

Related Questions