Files in Visual Basic

todo list
The "To-Do List" Program

This program reads and writes to a sequential file. Each line in the file is added to the ComboBox combobox and displayed.
  1. Using Notepad, create a short list of about 5 items and save it as C:\todo.txt.
  2. Start a new Windows application, name it ToDo.
  3. Add a ComboBox combobox to the form. Name it CboToDo.
  4. Add the following code to form load:
Private Sub Form1_Load(ByVal sender As System.Object, _
  ByVal e As System.EventArgs) Handles MyBase.Load
  Dim S As String = ""
  FileOpen(1, "C:\todo.txt", OpenMode.Input) 'open the file for input
  While Not EOF(1) 'EOF=End of file, this loops to read all recordds
     S = LineInput(1) 'read from file 1
     Me.CboTodo.Items.Add(S) 'add the item read to the combo box
  End While
  FileClose(1) 'close file 1
  If Me.CboTodo.Items.Count > 0 Then 'make sure the file was read
     Me.CboTodo.SelectedIndex = 0 'display 1st item in list
  End If
End Sub 'Form1_Load

NEXT: Creating a lookup list from a file