Solved

Create arraylists dynamically based on loop

Posted on 2010-09-07
5
469 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.

863 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

23 Experts available now in Live!

Get 1:1 Help Now