TEXT file csvSTOCKS.TXT contains the following:
Stock 1,200,300,200,200
Stock 2,200,300,200,200
Stock 3,200,300,200,200
Stock 4,200,300,200,200
Stock 5,200,300,200,200

I'm attempting to read each line in the text file and put it in the array of strings lines()

Dim sr As StreamReader = New StreamReader("csvSTOCKS.TXT")

        Dim lines() As String

        Do While (sr.Peek <> -1)
            lines = sr.ReadLine
        Loop

        lstOutput.Items.Add(lines(0))

BUT, I get the following error when I try to assign lines = sr.ReadLine
ERROR:

Error	1	Value of type 'String' cannot be converted to '1-dimensional array of String'.

If this cannot be done, is there a way to do that ?
tx

You have to redimension your lines array:

Dim sr As StreamReader = New StreamReader("csvSTOCKS.TXT")
        Dim lines() As String
        Dim index As Integer = 0

        Do While (sr.Peek <> -1)
            ReDim Preserve lines(index)
            lines(index) = sr.ReadLine
            index += 1
        Loop

or use an array list:

Dim sr As StreamReader = New StreamReader("csvSTOCKS.TXT")
        Dim lines As ArrayList = Nothing

        Do While (sr.Peek <> -1)
            lines.Add(sr.ReadLine)
        Loop
commented: Thanks great post and right to the point. +1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.