Solved

Create arraylists dynamically based on loop

Posted on 2010-09-07
5
468 Views
Last Modified: 2012-05-10
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)

0
Comment
Question by:sebastiz
  • 3
  • 2
5 Comments
 
LVL 47

Expert Comment

by:Wayne Taylor (webtubbs)
ID: 33616175
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
 
LVL 47

Accepted Solution

by:
Wayne Taylor (webtubbs) earned 500 total points
ID: 33616190
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
 

Author Comment

by:sebastiz
ID: 33616212
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
 
LVL 47

Assisted Solution

by:Wayne Taylor (webtubbs)
Wayne Taylor (webtubbs) earned 500 total points
ID: 33616439
Simply by index (zero based)...

    Dim arr2 As ArrayList = ArrayLists(1)

Wayne
0
 

Author Comment

by:sebastiz
ID: 33616850
Brilliant. Many thanks
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now