Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error 62: Input past end of file. Started today???

Status
Not open for further replies.

bigracefan

Programmer
Joined
Apr 2, 2002
Messages
304
Location
US
I have this application that has been running for over a month with no problems. Here is the code that I use to read the files:

StartChecking:

On Error GoTo ErrorTrap

SearchPath = gFolder & "\" & filename
intFileNum = FreeFile
i = 0
Close #intFileNum

MyFileName = Dir(SearchPath)
Open SearchPath For Input As #intFileNum
Do While Not EOF(intFileNum)
If i = 0 Then
Input #intFileNum, strValue(i, 0), strValue(i, 1), strValue(i, 2), strValue(i, 3), strValue(i, 4), strValue(i, 5), strValue(i, 6)
ElseIf i = 1 Then
Input #intFileNum, intValue(i, 0), strValue(i, 1), strValue(i, 2), strValue(i, 3), strValue(i, 4), strValue(i, 5), strValue(i, 6)
Else
Input #intFileNum, strValue(i, 0), strValue(i, 1), strValue(i, 2), intValue(i, 3), intValue(i, 4), intValue(i, 5), intValue(i, 6)
End If
i = i + 1
Loop


This is the actual data from a text file that is giving me the error.

,"TestName","Index","Status","Measured","LowLimit","HighLimit"

,"KCST Line #2 Aging #28",0,1,"2857","154198",20040119083439

,"F/S NG/70_2,AT1_4,AT7_4,AT16_3,AT23_3","",1,,,


The value of i=2. I've tried commenting the line of code back but I still get the same result. Any ideas?

Thanks.

 
Do you have a crlf after the last , ? If not it will fail.
I tried your data with all the crlf's deleted (I assume it's a continuos string) and the initial comma against the below and it was fine.
Try that and see if you can narrow down what is causing the problem.

Private Sub Form_Load()
Dim intFileNum As Integer
Dim a1, a2, a3, a4, a5, a6
intFileNum = FreeFile
i = 0
Open "c:\a.txt" For Input As #intFileNum
Do While Not EOF(intFileNum)
Input #intFileNum, a1, a2, a3, a4, a5, a6
i = i + 1
Loop
End Sub




======================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
 
Yes, there is a carriage return. Do you know anything about using some sort of buffer? I've found the following code. I don't know what the sBuffer is?

dim vArray as Variant
dim ii as integer


Open m_ExtractFile for Input as #1

Do While Not EOF(1)

Line Input #1, sBuffer

vArray = split(sBuffer,",")

For ii = 0 to uBound(vArray)
Debug.print vArray(ii)
Next

Loop

Close #1


 
split is just a function that splits the string up into an array - so sbuffer will just be a string into which is read lines of text.

Your code reads 6 fields at I time - this one reads up to the crlf at a time.

======================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
 
I used to use the split function until the the second field started having commas in it. Then I used the input method. I've got a work around on it now, but I need to find a permanent way to handle reading these files. Thanks for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top