Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
B

BubbaBeans

@BubbaBeans
About
Posts
2
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • List of List returning only copies of last list added
    B BubbaBeans

    Dang it... I KNEW that, too! I guess it is time to start drinking coffee again. Thanks to both of you!:thumbsup:

    Visual Basic database data-structures json tutorial question

  • List of List returning only copies of last list added
    B BubbaBeans

    I am attempting to create a list of lists so I can return a specific list when I reference list(index), for example. I created a custom class and am using it as the list type. A subroutine reads through a text file (csv) one line at a time. The value in the line indicates the "section number" to which the rest of the line belongs, and all other values on that line are used to set certain properties in my custom class. (Confusing?) Basically it reads through the lines, and if the first number is the same as the first number in the previous line, it processes the line and adds it to a list. If the number is different, it adds the list to the main list, then clears the list, and adds the current line to the new list. And repeat until the end of the file. Here is the code:

    Dim EvalTopics As new List(of List(of customClass))
    Dim sr As StreamReader = New StreamReader(BLAHBLAHBLAH)
    Dim OldSec As Integer = 0, NewSec As Integer = 0 'Old and New Section Numbers
    Dim seclist As New List(Of customClass) 'List to be added to EvalTopics
    While Not sr.EndOfStream
    Dim splits() As String = sr.Readline.Split(",")
    NewSec = splits(0) 'Section # is first value
    If OldSec <> NewSec Then
    EvalTopics.Add(seclist)
    seclist.Clear()
    OldSec = NewSec
    End If
    Dim es As customClass = New customClass
    With es
    'assign the other values to various properties
    End With
    seclist.Add(es)
    End While
    EvalTopics.Add(seclist)'Add the last section
    sr.Close()

    After populating the lists, if I call up EvalTopics(0), I get the same as EvalTopics(3). In fact, every list I call up is the same as the LAST LIST ADDED. Can someone point me in the right direction? At first I thought I was using lists incorrectly, so I tried an array of lists, then a list of arrays. Nothing worked.

    Visual Basic database data-structures json tutorial question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups