我一直在这里收到错误,这个程序的目标是读取我制作的文件类型(.ptaf纯文本存档格式),但它一直返回此错误:
变量未定义:“输入”
Option Explicit
Const conForReading = 1
'Declare variables
Dim objFSO, objReadFile, contents
'Input
Input = InputBox("Please enter the path of the file you want to open:", _
"Open Plain Text Archive File File")
'Set Objects
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objReadFile = objFSO.OpenTextFile("C:\MyArchives\"& Input.Value , 1, False)
'Read file contents
contents = objReadFile.ReadAll
'Close file
objReadFile.close
'Display results
wscript.echo contents
'Cleanup objects
Set objFSO = Nothing
Set objReadFile = Nothing
Thanks,
-------
Mr.Minecrafter
--------------
答案 0 :(得分:1)
试试下面的
Set objReadFile = objFSO.OpenTextFile("C:\MyArchives\"& Input, 1, False)
答案 1 :(得分:1)
您需要Dim
变量Input
(并按照@ AshReva的建议 - Input
不是对象)。