800A0401 - “输出”的预期结束

时间:2017-08-29 00:47:17

标签: vbscript

我收到错误

  

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"

1 个答案:

答案 0 :(得分: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了解详情。