File input loop

Situation: 

You have a file with data that you want to process. The amount of data in the file could change.

Actions: 

Use a Do-Loop to read data from the file. Loop until the program reaches EOF (end of file). See a flowchart and code in the this pattern's Explanation.

Explanation: 

Flowchart

  1. Private Sub cmdLoop_Click()
  2.     Dim sale As Single
  3.     'Open data file for input.
  4.     Open ThisWorkbook.Path & "\sales.txt" For Input As #1
  5.     Do While Not EOF(1)
  6.         Input #1, sale
  7.         'Do something with sale data...
  8.     Loop
  9.     'Close.
  10.     Close #1
  11. End Sub