P
Patrick Sullivan
I am trying to read a text file laid out like, "textfield1, textfield2,
etc," and only extract the first value (textfield1) to add to the listbox.
But instead of listing vertically, I get three rows across of textfield1,
which is the correct data, but not the correct format. I put a crlf in the
lines, but that did not help at all. TIA
Private Sub LoadListbox()
Try
Dim sr As StreamReader = New StreamReader("Names.txt")
Dim line As String
line = sr.ReadLine()
Do Until sr.Peek = -1
line = sr.ReadLine()
'MsgBox("Line is " & line.Length & " long")
lstNames.Items.Add(line.Substring(0, (line.IndexOf(","))) & vbCrLf)
Loop
sr.Close()
Catch E As Exception
MsgBox("The file could not be read")
MsgBox(E.Message)
End Try
End Sub
etc," and only extract the first value (textfield1) to add to the listbox.
But instead of listing vertically, I get three rows across of textfield1,
which is the correct data, but not the correct format. I put a crlf in the
lines, but that did not help at all. TIA
Private Sub LoadListbox()
Try
Dim sr As StreamReader = New StreamReader("Names.txt")
Dim line As String
line = sr.ReadLine()
Do Until sr.Peek = -1
line = sr.ReadLine()
'MsgBox("Line is " & line.Length & " long")
lstNames.Items.Add(line.Substring(0, (line.IndexOf(","))) & vbCrLf)
Loop
sr.Close()
Catch E As Exception
MsgBox("The file could not be read")
MsgBox(E.Message)
End Try
End Sub