Multidimensional Arraylist

  • Thread starter Thread starter RSH
  • Start date Start date
R

RSH

I have a situation where I need to use a multidimenstional Array in a
dynamic environment. i need to be able to iterate through the loop easily
and I dont know the dimensions so i was trying to find a way to use an
arraylist.

Basically i need to store a list of psuedo properties like so:


Dim aList1 As New ArrayList

Dim aList2 As New ArrayList

Dim Count1 As Integer

Dim Count2 As Integer

aList2.Add("ID") 'Name

aList2.Add("1") 'Ordinal

aList2.Add("16") ' Flags

aList2.Add("0") 'Size

aList2.Add("1") 'DataType

aList2.Add("0") 'Precision

aList2.Add("0") 'Numeric Scale

aList2.Add("False") 'Nullable

aList1.Add(aList2)

------

aList2.Add("COL1") 'Name

aList2.Add("2") 'Ordinal

aList2.Add("16") ' Flags

aList2.Add("0") 'Size

aList2.Add("1") 'DataType

aList2.Add("0") 'Precision

aList2.Add("0") 'Numeric Scale

aList2.Add("False") 'Nullable

aList1.Add(aList2)

MessageBox.Show(aList2.Count)

For Count1 = 0 To aList1.Count - 1

For Count2 = 0 To aList1(Count1).Count - 1

RTB.Text += aList1(Count1)(Count2) & vbCrLf

Next

RTB.Text += vbCrLf

Next













Output:

ID

1

16

0

1

0

0

False

COL1

2

16

0

1

0

0

False

ID

1

16

0

1

0

0

False

COL1

2

16

0

1

0

0

False











Obviously that isn't going to work. What is the proper way to do this?



Thanks,

RSH
 
RSH,

Create a class with properties for Name, Ordinal, Flags, Size, etc.

Create an object from the class and fill in the object's properties with
data, such as ID, 1, 16, etc.

Then add the object to an arraylist.

Process the arraylist with a For Each loop.

Kerry Moorman
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top