iT邦幫忙

0

求救 vbs 讀檔後處理輸出txt檔,都是空白

https://ithelp.ithome.com.tw/upload/images/20200310/201239948ldg4xfcPW.jpg
讀入txt後可以顯示出來,但是輸出txt都是空白
我想上圖輸出txt 內容變成下圖那裡
程式是那裡有問題,一直無法達到目的
可以幫我看一下要如何修改
dim j,c,s
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("d:\new\126.txt", 1)
strContents = objFile.ReadAll
Do While objFile.AtEndOfStream = False
j=left(strContents,32)
c=right(strContents,5)
s=j&c
Loop
Set fso = CreateObject("Scripting.FileSystemObject")
Set file = fso.CreateTextFile("d:\new\125.txt", True)
file.WriteLine (s)

最後沒有close文件吧,最後加一句
file.Close
試試
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

0
海綿寶寶
iT邦大神 1 級 ‧ 2020-03-11 07:55:46

試試看

dim j,c,s
Set fso = CreateObject("Scripting.FileSystemObject")
Set file = fso.CreateTextFile("d:\new\125.txt", True)

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("d:\new\126.txt", 1)

Do Until objFile.AtEndOfStream
    strContents = objFile.ReadLine
    j=left(strContents,32)
    c=right(strContents,5)
    s=j&c
    file.WriteLine (s)
Loop

objFile.Close
file.Close

我要發表回答

立即登入回答