Facebook

Course Name Start Date Time Duration Registration Link
No Training Programs Scheduled ClickHere to Contact
Please mail To sudhakar@qtpsudhakar.com to Register for any training

Wednesday, June 10, 2009

How to update a particulare line in a text file?

'**************************************************************
txtFilePath= "C:\abc.txt"
txtRowNumber=3 ' Row number to update
TextToAdd="three"

Set fso= CreateObject( "scripting. FilesystemObject ")
Set f=fso.OpenTextFile( txtFilePath, 1)
txtData=f.readall
f.close

Set f=fso.OpenTextFile( txtFilePath, 2)

strTxtData=split( txtData,vbnewlin e)

For cnt=0 to ubound(strTxtData)


If cnt<>txtRowNumber- 1 Then
    f.writeline( strTxtData( cnt))
else
    f.writeline( TextToAdd )
End If

Next

f.close
'**************************************************************

No comments :

Post a Comment