0

我试图在文本文件的每一行中的某些点放置一个垂直条。我的代码非常简单,我很确定……但是当我尝试运行它时,什么也没有发生。我什至没有收到错误。它应该写入的文件只是一个空白文本文件

Const ForReading = 1
Const ForWriting = 2

arrCommas =  Array(10,14,21,24,39,43,46,61,72,79,82,85,88,91,94,97,101,142,173,189,192,198,205,211,218,222,229,236,240)

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("c:\SQL DATA FILES\MBS Stats\mbsedited\mbsfact102013_linebreaks.txt", ForReading)

Do Until objFile.AtEndOfStream
strLine = objFile.ReadLine
intLength = Len(strLine)
For Each strComma in arrCommas
    strLine = Left(strLine, strComma - 1) + "|" + Mid(strLine, strComma, intLength)
Next
strText = strText & strLine & vbCrLf
Loop

objFile.Close

Set objFile = objFSO.OpenTextFile("c:\SQL DATA FILES\MBS Stats\mbsfinal\mbsfact102013_delimited.txt", ForWriting)
objFile.Write strText
objFile.Close
4

1 回答 1

-1
Const ForReading = 1
Const ForWriting = 2

arrCommas =  Array(10,14,21,24,39,43,46,61,72,79,82,85,88,91,94,97,101,142,173,189,192,198,205,211,218,222,229,236,240)

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("c:\SQL DATA FILES\MBS Stats\mbsedited\mbsfact102013_linebreaks.txt", ForReading)

strTextFile = objFile.ReadAll
objFile.Close

aTextFile = Split(strTextFile, vbCRLF)

strText = ""
For Each strLine In aTextFile
    intLength = Len(strLine)
    For Each strComma in arrCommas
        strLine = Left(strLine, strComma - 1) + "|" + Mid(strLine, strComma, intLength)
    Next
    strText = strText & strLine & vbCrLf
Next

Set objFile = objFSO.OpenTextFile("c:\SQL DATA FILES\MBS Stats\mbsfinal\mbsfact102013_delimited.txt", ForWriting)
objFile.Write strText
objFile.Close
于 2013-11-15T20:32:30.340 回答