[VB.NET] Open txt file into a listbox
of1 = Openfiledialog's name
lstaccounts = list box you wish to have items added to
Put this code in the open button...
lstaccounts = list box you wish to have items added to
of1.InitialDirectory = "C:/"
of1.FileName = "accounts.txt"
of1.Title = "Open Accounts List..."
of1.Filter = ("text files (*.txt) | *.txt")
of1.ShowDialog()
Dim r As IO.StreamReader
r = New IO.StreamReader(of1.FileName)
While (r.Peek() > -1)
lstaccounts.Items.Add(r.ReadLine)
End While
r.Close()Put this code in the open button...