Home > DeveloperSection > Forums > How to work with Nested ArrayLists in VB
Pravesh Singh

Total Post:411

Points:2881
Posted on    June-11-2013 5:22 AM

 VB.Net VB.Net 
Ratings:


 1 Reply(s)
 780  View(s)
Rate this:
Hi Everyone,

I'm try to work with Nested ArrayList in VB.Net. Where i'm wrong? Is there a better way of doing it? 
For some reason my code passes right through the printing code without outputting anything at all. 

My line of code as following

    Dim k As New List(Of String)
    Dim a As New List(Of List(Of String))
       For fc = 1 To 2
          k.add("hi")
          k.add("hey")
          k.add("bye")
          a.add(k)
          k.clear()

 ########Printing Stuff

    Dim i As Integer
    For i = 0 To a.Count - 1
        Dim sstr As String
        For Each sstr In a.Item(i)
            MsgBox(sstr)
        Next
    Next i

Any help would be amazing thank you!




AVADHESH PATEL

Total Post:604

Points:4228
Posted on    June-12-2013 8:12 AM

Hi Pravesh,

In place of k.clear try k = new List(Of String) in each loop. 

I hope it resolve your problem. 


Don't want to miss updates? Please click the below button!

Follow MindStick