2017-08-29 77 views
-4

我收到錯誤800A0401 - 預期的 「輸出」

800A0401語句的結束 - 聲明

在VBScript

的預期結束。

enter image description here

請什麼是錯的澄清。

Const ForReading = 1 
Set objFSO = CreateObject("Scripting.FileSystemObject") 
Set objTextFile = objFSO.OpenTextFile("C:\Users\RAJDIQ\Desktop\Macros\11082017\SingleFile.txt", ForReading) 
strLine = objTextFile.ReadLine 
Set folder = objFSO.GetFolder("C:\Users\RAJDIQ\Desktop\Macros\11082017\") 
Set outfile = objFSO.OpenTextFile("C:\Users\RAJDIQ\Desktop\Macros\11082017\comparedel.txt") 
myFile ="C:\Users\RAJDIQ\Desktop\Macros\11082017\Output.txt" 
Open myFile for Output As #1 
t = 0 
Do Until outfile.AtEndOfStream 
    strLine = outfile.ReadLine 
    If InStr(strLine, substrToFind) <> 0 Then 
    t = t+1 
    Else 
    [ Lines = Lines & t & "," 
    Write #1, Lines] 
    End If 
Loop 

MsgBox "Complete" 
+2

''Lines = Lines&t&「,」'不是有效的VBA語句。你想用那個'['?]做什麼? – YowE3K

+0

也不是'寫入#1,行]'。 –

+0

我用|來記錄每條記錄分隔並與其他文件進行比較。沒有匹配的記錄,我正在挑選沒有匹配的線。 – DevR

回答

0

你讓VBA與VBScript混淆。 Open myFile for Output As #1不是有效的VBScript代碼,也不是Write #1或方括號。在VBScript中,您通過FileSystemObject處理文件。

Set outputFile = objFSO.OpenTextFile(myFile, 2, True) 
'stuff 
outputFile.WriteLine "something" 
'more stuff 
outputFile.Close 

參數2打開文件進行寫入,參數True確保文件被創建的情況下,它缺少。

請查閱documentation瞭解更多詳情。