Input Function [VBA]

Returns the open stream of an Input or Binary file (String).

警告图标

该功能或常量可通过以下语句启用:Option VBASupport 1,该语句需要放置在模块的每个可执行程序代码的前面。


语法:

Input( Number as Integer, [# ] FileNumber as Integer)

返回值:

String

参数:

Number: Required. Numeric expression specifying the number of characters to return.

#: Optional.

FileNumber: Required. Any valid file number.

错误代码:

6 溢出

52 错误的文件名或编号

62 读取内容超出 EOF

示例:

REM ***** BASIC *****

Option VBASupport 1

Sub Example_Input

 Dim MyData

 Open "MyDataFile.txt" For Input As #1

 Do While Not EOF(1)

  MyData = Input(1, #1)

  Print MyData

 Loop

 Close #1

End Sub