Create arraylists dynamically based on loop

I have a textbox with some text in it. I have a loop that retrieves bits of the text based on a regular expression and stores it in a listbox.
I then have a second loop which takes each value in this listbox and retrieves bits of the text in the textbox with a regular expression based on each value from the first listbox, and stores all of it in another listbox.
I would like to create an array list for each value in the first listbox which stores the retrieved bit of text for that value from the second loop.
I guess the question is about how to create a number of new arraylists programmatically based on how many items are in a listbox...... (in vb.net)

sebastizAsked:
Who is Participating?
 
Wayne Taylor (webtubbs)Connect With a Mentor Commented:
Might have misread what you are doing.

Sounds like you could use a List of ArrayLists....

    Dim ArrayLists As New List(Of ArrayList)
    For 'whatever your loop is
        Dim arr As New ArrayList()
        'add items to arr
        ArrayLists.Add(arr)
    Next

Wayne
0
 
Wayne Taylor (webtubbs)Commented:
ArrayLists are resizable, so you don't need to know how many items it will hold.

http://msdn.microsoft.com/en-us/library/system.collections.arraylist.aspx

Wayne
0
 
sebastizAuthor Commented:
Great. How do I then reference the arraylist within the arraylist. Lets say I then want to loop through the second arrayllist in the parent arraylist?
0
 
Wayne Taylor (webtubbs)Connect With a Mentor Commented:
Simply by index (zero based)...

    Dim arr2 As ArrayList = ArrayLists(1)

Wayne
0
 
sebastizAuthor Commented:
Brilliant. Many thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.