English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I have written a program that reads ASCII files and displays them but at the end of the file it will stop. I would like it to loop back round to the start of the file but don't know how to use the EOF function or command, or how to detect the end of the file. Could someone give me an example or explain it to a very amatuer programmer like myself.

Thanks in advance

andy

2007-07-17 03:38:43 · 2 answers · asked by Andy 4 in Computers & Internet Programming & Design

2 answers

Dim TextLine As String
FileOpen(1, "TESTFILE", OpenMode.Input) ' Open file.
Do While Not EOF(1) ' Loop until end of file.
TextLine = LineInput(1) ' Read line into variable.
Debug.WriteLine(TextLine) ' Print to the Command window.
Loop
FileClose(1) ' Close file.

2007-07-17 03:44:25 · answer #1 · answered by Del Piero 10 7 · 1 0

Once you have opened your file, you use:
do while not EOF(filenumber)
- do things
loop
This will read the file from top to bottom.
To reset the file pointer, you have to close the file and reopen it...
It use to be a function fseek(handle, location). Seems to have disappeared for a seek function that works only on records.

2007-07-17 04:44:16 · answer #2 · answered by just "JR" 7 · 1 0

fedest.com, questions and answers