2016-12-02 121 views
0

請問您可以告訴下面的VBScript有什麼問題嗎?我得到這個錯誤:error expected ')'在Windows上運行.vbs時出現錯誤,預計')'vb腳本

的VBScript:

Const strSourceFile = "C:\Temp\test.txt" 
Const strTargetFile = "C:\Temp\test.csv" 
Dim strData 
Dim objFSO, objSourceFile, objTargetFile 
Set objFSO = CreateObject("Scripting.FileSystemObject") 
Set objSourceFile = objFSO.OpenTextFile(strSourceFile, 1, True) 
Set objTargetFile = objFSO.CreateTextFile(strTargetFile, True) 

Do While Not objSourceFile.AtEndOfStream 
    strData = objSourceFile.ReadLine 
    'msgbox strData 

    Dim strName, strAddress, strCity, strState, strZip 

    strName = Trim(Mid(strData, 1, 20)) 
    strAddress = Trim(Mid(strData, 21, 20)) 
    strCity = Trim(Mid(strData, 41, 20)) 
    strState = Trim(Mid(strData, 61, 2)) 
    strZip = Trim(Mid(strData, 63 5)) 

    objTargetFile.WriteLine("""" & strName & """,""" & strAddress & """,""" & strCity & """,""" & strState & """,""" & strZip & """") 
Loop 

msgbox "done!" 

回答

1

也許

strZip = Trim(Mid(strData, 63, 5)) 

(缺少逗號)

+0

謝謝托馬斯!感謝你的幫助! – user3276905

相關問題