' Ch 9 Demo 2
' Mr. Minich
' Purpose - to illustrate reading from a sequential file and detecting the EOF (end of file)
Option Explicit
Private Sub Form_Load()
Open "Z:\Basic\Ch 9\Ch9Demo2\ch9demo2data.txt" For Input As #1
End Sub
Private Sub cmdNext_Click()
Dim strQuestion As String ' next question
If (Not(EOF(1))) Then ' if the end of file #1 has not occurred yet
Input #1, strQuestion ' read the next question
Else
Close #1 ' otherwise close the file
MsgBox "Goodbye"
Unload Me
End If
lblQuestion.Caption = strQuestion
End Sub