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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Write in a specific line of a file 2

Status
Not open for further replies.

Gti

Programmer
Jul 23, 2001
99
PT
I need to write in a specific line of a file... How can i do this?
 
You must Create a temp file and write there the data you want from your original file . Then rename the tempFile as the original's file name ( After you delete it of course )

This is the source code :

LineToReplace = X
LineToRead = 0
Open "filename.txt" for input as #1
Open "###.$$$" For Output As #2
while not eof(1)
LineToRead =LineToRead + 1
if LineToReplace = LineToRead then
strLine = "Replace With This"
else
Read #1, strLine
end if

Print #2, strLine
wend

Close #1
Close #2

Kill "filename.txt"
Name "###.$$$" As "filename.txt"

Hope this Helps ....
svagelis
 
And how i'm going to get de "LineToReplace" and "LineToRead"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top