返回列表 上一主題 發帖

[發問] 求救 vbs輸出txt檔案格式程式修正

[發問] 求救 vbs輸出txt檔案格式程式修正


上圖為螢幕輸出

此圖為輸出為txt檔案時的格式,與螢幕輸出格式不一致
下為程式碼
如何在txt檔案輸出與螢幕輸出一樣
可以幫我看一下檔案輸出程式要如何修改
Set objRegEx = CreateObject("VBScript.RegExp")
Dim arrFileLines()
AAA = ""
i = 0
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("d:\input.txt", 1)
Do Until objFile.AtEndOfStream
Redim Preserve arrFileLines(i)
arrFileLines(i) = objFile.ReadLine
i = i + 1
Loop
objFile.Close

Set objRegEx = CreateObject("VBScript.RegExp")
objRegEx.Pattern = "\d{5}"
For l =  LBound(arrFileLines) to UBound(arrFileLines)
if l <10 then
strNewString = objRegEx.Replace(arrFileLines(l),"0000" & (l+1) )
AAA = AAA & strNewString & chr(10)
else
strNewString = objRegEx.Replace(arrFileLines(l),"000" & (l+1) )
AAA = AAA & strNewString & chr(10)
end if
next

Wscript.Echo AAA
Dim fso, MyFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = fso.CreateTextFile("d:\outfile.txt", True)
MyFile.WriteLine(AAA)
MyFile.Close

換行改成chr(10)+chr(13) 試試

TOP

        靜思自在 : 心中常存善解、包容、感思、知足、惜福。
返回列表 上一主題