Vic Li <li*****@uq.edu.au> wrote in message news:<41**********************@news.newsgroups.ws> ...
Thanks a lot. Is there is a way to search the file one line by one line?
It's actually a series of records, in each line, i need to find all d
with a comma behind and replace it with space. Then write it out.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Try this:
dim fso as object
dim txtStr as object
dim strHolder as string
dim strFileToFix as string
dim strTemp
strFileToFix = "PATHTO FILE"
set fso = wscript.createobject("scripting.filesystemobject")
set txtStr = fso.opentextfile(strFileToFix,1,false,0)
do until txtStr.atendofstream
strTemp = txtStr.readline
strTemp = replace(strTemp,"string to
find",space(1),1,-1,vbtextcompare)
strHolder = strHolder & strTemp & vbcrlf 'not sure you need vbcrlf or
not i think you do
next
txtStr.close
set txtStr = nothing
set txtStr = fso.createtextfile(strFileToFix,true,false)
txtStr.write(strHolder)
txtStr.close
set txtStr = nothing
Just a side note. I would suggest you pick up a copty of
VBScript in a Nutshell published by O'Reilly. The first
edition is OK and is just a tremendous resource. No real need to get
the second edition if you want to be cheap. Dirt cheap used on the
internet.
Finally there was a bug in the first post should be space(1) not
space(0).