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 strongm 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

Status
Not open for further replies.

jshanoo

Programmer
Apr 2, 2002
287
IN
Hi all,
i have following piece of code,
I am trying open a text file and put in a string
***************************************************
Dim strMailMessage As String, FSO As FileSystemObject, F
Const ForReading = 1, ForWriting = 2, ForAppending = 3
Set FSO = New FileSystemObject

Set F = FSO.OpenTextFile(MFile, ForReading, TristateFalse)
strMailMessage = F.ReadAll
*****************************************************
in 'F.readall' it gives error

like Error # 62 ;Input past end of file

can anyone please help me in this.





*** Even the Best, did the Bad and Made the Best ***

John Philip
 
Hi all,
Any solution for this?


*** Even the Best, did the Bad and Made the Best ***

John Philip
 
I never use the FSO.
I do it manually.
If it is a text file you need to read in try this.

Dim MailMessage as String

Private Sub LoadFile(FileName as String)
Open FileName for input as #1
while not EOF(1)
input #1, MailMessage
msgbox MailMessage
wend
close #1
End Sub

Private Sub Command1_Click
LoadFile("C:\Test.Txt")
End Sub

There where the message box is you can move the mailmessage to a collection or Array or use it in which ever way possible. each time it comes to the MsgBox command only one record has been read in, the next time it comes there it will then be the next record in the file. If you would like to read more than one var in the input statement use :

input #1, Var1, Var2, ect.

When Writing to a file do it as follows:

open FileName For output as #1
Write #1, Var1, Var2, Ect.
close #1

You can also put the write command in a loop like a do loop or while loop to make it write multiple records to a file.
for each write command there will be one record added to the file
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top