HOW TO WORK WITH NESTED ARRAYLISTS IN VB

Pravesh Singh

Total Post:412

Points:2888
Posted by  Pravesh Singh
VB.Net 
 990  View(s)
Ratings:
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!


  1. AVADHESH PATEL

    Post:604

    Points:4228
    Re: How to work with Nested ArrayLists in VB

    Hi Pravesh,


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

    I hope it resolve your problem. 

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!