954,517 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How do I code a multidimensional array?

What I need, is one three-dimensional array that holds:

1. Column name
2. MaxLength
3. DataType

My code is close, I just can't remember the syntax for adding data to the array.

Please help,
Sheryl

'get the column information
                    Dim c As Integer = 0
                    Dim x As Integer = 0
                    Dim y As Integer = 0
                    Dim iCount As Integer = columnCount - 1
                    Dim aFields(iCount, iCount, iCount) As String
                    For Each dc As DataColumn In objDS.Tables(strTableName).Columns
                        aFields(c, x, y) = dc.ColumnName
                        aFields(c, x, y) = dc.MaxLength.ToString
                        aFields(c, x, y) = dc.DataType.ToString
                        frmDesigner.ListBox1.Items.Add(aFields(c, x, y))
                        c = c + 1
                        x = x + 1
                        y = y + 1
                    Next
Sheryl99
Light Poster
27 posts since Sep 2008
Reputation Points: 10
Solved Threads: 0
 

You mean declare a class and have the those objects in a one dimensional array?

iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
 

As long as I can reference each item separately, that's what I need. Thanks.

Sheryl99
Light Poster
27 posts since Sep 2008
Reputation Points: 10
Solved Threads: 0
 

I think I figured it out. The following code puts each of the three items into the array. This may not be the best way to do it, so I'm open to suggestions.

~ Sheryl

Dim aFields(iCount, 2) As String
                    For Each dc As DataColumn In objDS.Tables(strTableName).Columns
                        aFields(c, 0) = dc.ColumnName
                        afields(c, 1) = dc.MaxLength.ToString
                        aFields(c, 2) = dc.DataType.ToString
                        c = c + 1
                  Next
Sheryl99
Light Poster
27 posts since Sep 2008
Reputation Points: 10
Solved Threads: 0
 

If it works it works, but I'd recommend reading up on classes as they form an integral part of code design.

iamthwee
Posting Expert
5,950 posts since Aug 2005
Reputation Points: 1,543
Solved Threads: 439
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You