View contents of this chapter

Example - Sequential Access

The source code needed for this example is stored in the "Source Code\Chapter18\Sequential" directory.

Private Sub cmdRead_Click()
   Dim strLine As String
   Open App.Path & "\numbers.txt" For Input As #1

   'clear the list box
   lstShow.Clear
   Do Until (EOF(1))
      Line Input #1, strLine
      'add data to the list box
      lstShow.AddItem strLine
   Loop
   Close #1

End Sub

When the user clicks the cmdRead button, the program opens a file named "numbers.txt" for sequential access, reads data from that file and adds data to a list box(lstShow). The EOF Function returns an Integer containing the Boolean value True when the end of a file opened for Random or sequential Input has been reached.



© Universal Teacher Publications        INDEX Previous Screen Next Screen