I have a text file that contains three lines and is formatted as follows:
"Prefix","Sequential #","Ignore this Field"
"Ignore this Field"
"Ignore this Field"
The following code is meant to read the whole file and increment the sequential number by 1 and write out all three lines - I hoped. It just writes the first line. Can someone recommend what needs to be changed. The fields ignored although not used in this instance need never-the-less to be written.
' Begin Code --->
Const ForReading = 1
Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("F:\MXFEK.ZMN", ForReading)
strLine = objFile.ReadLine
strResult = Split(strLine, ",") ' 0 = Pseudo Contact Prefix 1 = seqNum 2 = Skip Field
seqNum = Replace(strResult(1), Chr(34), "") + 1
strLine = strResult(0) & "," & Chr(34) & seqNum & Chr(34) & "," & strResult(2)
objFile.Close
Set objFile = objFSO.OpentextFile("F:\MXFEK.ZMN", ForWriting)
objFile.WriteLine strLine
objFile.Close
<--- End Code
Thanks
Iris
"Prefix","Sequential #","Ignore this Field"
"Ignore this Field"
"Ignore this Field"
The following code is meant to read the whole file and increment the sequential number by 1 and write out all three lines - I hoped. It just writes the first line. Can someone recommend what needs to be changed. The fields ignored although not used in this instance need never-the-less to be written.
' Begin Code --->
Const ForReading = 1
Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("F:\MXFEK.ZMN", ForReading)
strLine = objFile.ReadLine
strResult = Split(strLine, ",") ' 0 = Pseudo Contact Prefix 1 = seqNum 2 = Skip Field
seqNum = Replace(strResult(1), Chr(34), "") + 1
strLine = strResult(0) & "," & Chr(34) & seqNum & Chr(34) & "," & strResult(2)
objFile.Close
Set objFile = objFSO.OpentextFile("F:\MXFEK.ZMN", ForWriting)
objFile.WriteLine strLine
objFile.Close
<--- End Code
Thanks
Iris