nutsukae

i have file a.txt in my file have a lot of lines like this

Code Snippet

a.txt

111111111111111235646
123156468543
1235498
1235498
12546



how can i read it in line and put them to listbox

thank for coming


Re: Visual Basic General how can i read data from file

DigBoy2000

Use a streamreader to read the file and add the items to the listbox line by line.

Code Snippet

Private Sub GetData()

ListBox1.Items.Clear()

Dim sr As New IO.StreamReader("C:\a.txt")

Try

Do While sr.Peek <> -1

ListBox1.Items.Add(sr.ReadLine)

Loop

Catch ex As Exception

MessageBox.Show(ex.Message)

Finally

sr.Close()

End Try

End Sub





Re: Visual Basic General how can i read data from file

nutsukae

thank you very much