Reading Text File

  • Thread starter Thread starter Roy Goldhammer
  • Start date Start date
R

Roy Goldhammer

Hello there

I've build program that Read Text file and store it on Access table
according to Structure

i read the data using Line Input command

Is there a way to know what is the actual Location on the file i'm right
now?

And is there a way to know what is the size of the file?

so i can show to the user in percent the process of reading text file?

--
øåòé âåìãäîø
ù.î. òúéã äðãñú úåëðä
(e-mail address removed)
èì: 03-5611606
ôìà' 050-7709399
 
You can determine the total size of the file using the FileLen function.

Assuming you're using Line Input to read each line into a variable, you can
use the Len function on that variable after each read to determine where you
are in the file.

Something like the following untested air-code:

Dim intFile As Integer
Dim lngCurr As Long
Dim lngTotal As Long
Dim strBuffer As String
Dim strFile As String

strFile = "<full path to file>"
lngTotal = FileLen(strFile)
intFile = FreeFile
Open strFile For Input As #intFile
Do While Not EOF(intFile)
Line Input #intFile, strBuffer
lngCurr = lngCurr + Len(strBuffer)
' At this point, you've read lngCurr characters
' (out of a total lngTotal characters in the file)
Loop
Close #intFile
 
Back
Top