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

how to add string in text file

Status
Not open for further replies.

modzho

Technical User
Sep 18, 2003
3
LV
hello.

how to do this ?

input textfile looks like this
1.000000
0.000000
0.000000
-1.000000
20000.000000
10000.000000

output what i want look like this

1.000000
0.000000
0.000000
-1.000000
20000.000000
910000.000000

i just want to add one number at the last line in this examle is 9, then save this file and that all.
 
you will have to read the whole text file to a string, and then reopen the text file for writing. You then write the new textstring over the existing.

reference MS Scriting runtime

dim fso as new filesystemobject
dim ts as textstream
dim mystring as string

set ts=fso.opentextfile(myfilename,forreading)
mystring=ts.readall
ts.close

edit mystring to be what the file should read

set ts=fso.opentextfile(myfilename,forwriting)
ts.write mystring
ts.close

BB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top