Thanks rajpes for ur time. I have already thought of your suggestion first. I dont want to delete and create again. I want to do it in one shot.
I found one solution for it..and it is working for me.
My objective was to open a notepad, get its content, perform some matematical operations and generate a new string and finally write the new string to the file..
Regards,
Ankesh
I found one solution for it..and it is working for me.
My objective was to open a notepad, get its content, perform some matematical operations and generate a new string and finally write the new string to the file..
Code:
Const ForReading = 1, ForWriting = 2
Const TristateUseDefault = -2
strFilePath="C:\xyz.txt"
Set fso = CreateObject("Scripting.FileSystemObject")
Set fileObject = fso.GetFile(strFilePath)
Set ts = fileObject.OpenAsTextStream(ForReading, TristateUseDefault)
objText = ts.ReadLine
print objText
strTest=Split(objText,vbTab)
'Split and get the value
strVar1=strTest(0)
strVar2=strTest(1)
strVar3=strTest(2)
strVar4=strTest(3)
strVar5=strTest(4)
strVar6=strTest(5)
strVar7=strTest(6)
strVar8=strTest(7)
strVar9=strTest(8)
strVar10=strTest(9)
'Get the values on which the operation has to be performed
strVar5=strVar5+1
strVar6=strVar6+1
strVar7=strVar7+0.01
strVar8=strVar8+0.01
strVar9=strVar9+0.01
strVar10=strVar10+0.01
'Create a new string to be written to file
strNewString=strVar1&vbTab&strVar2&vbTab&strVar3&vbTab&strVar4&vbTab&strVar5&vbTab&strVar6&vbTab&strVar7&vbTab&strVar8&vbTab&strVar9&vbTab&strVar10
print strNewString
ts.Close
'Open the file and write the content to the file. This will replace the old content
Set ts = fileObject.OpenAsTextStream(ForWriting, TristateUseDefault)
ts.Write strNewString
ts.Close
Set fso=NothingRegards,
Ankesh

