1
我必須使用VBScript在文本行中的某些點插入逗號。我需要它來檢查每行的前四個charcters與if語句,如果它匹配它插入該行爲此所需的逗號是我到目前爲止有:如何在文本中插入逗號?
Const ForReading = 1
Const ForWriting = 2
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("H:\Letter Display\Letters\LTRPRT__00000008720000000001NI-K-RMND.txt", ForReading)
strNIK = "1000"
strLine = objFile.ReadLine
If Left(strLine,4) = strNIK then
arrCommas = Array(16,31,46,56,66,79,94,99)
Do Until objFile.AtEndOfStream
intLength = Len(strLine)
For Each strComma in arrCommas
strLine = Left(strLine, strComma - 1) + "," + Mid(strLine, strComma, intLength)
Next
strText = strText & strLine & vbCrLf
Loop
end if
objFile.Close
Set objFile = objFSO.OpenTextFile("H:\Letter Display\Letters\LTRPRT__00000008720000000001NI-K-RMND.txt", ForWriting)
objFile.Write strText
objFile.Close
如果任何人都可以用做此幫助一個IF聲明,將不勝感激。
非常感謝,你能告訴我如何做一個目錄中的每個文件都具有相同的擴展名.LTR? –