opening a text file in a list box
I've been trying to open a text file that i have created in windows notepad, to open up into a list box that i have created in a windows form. But im confused with the coding. If someone could possibly explain this to me in simple terms it would be great. Thanks.
Re: opening a text file in a list box
bboy_romeo,
Code:
Dim file As IO.StreamReader
Dim MyStr as String
Dim filename As String ="YourFileNameHere.txt"
file = New IO.StreamReader(filename, System.Text.Encoding.Default)
MyStr = file.Readline()
While Not MyStr Is Nothing
ListBox1.Items.Add(MyStr)
MyStr = file.Readline()
End While
file.Close()
Hope it helps