Input Function

Description

Returns characters (bytes) from an open sequential file.

Syntax

Input(number,[#]filenumber)

The Input function syntax has these parts:

Part

Description

number

Any valid numeric expression specifying the number of characters to return.

filenumber

Any valid file number.


Remarks

Use this function only with files opened in Input or Binary mode.

Unlike the Input # statement, the Input function returns all of the characters it reads including commas, carriage returns, linefeeds, quotation marks, and leading spaces.

Note

Another function (InputB) is provided for use with the double-byte character sets (DBCS) used in some Asian locales. Instead of specifying the number of characters to return, number specifies the number of bytes. In areas where DBCS is not used, InputB behaves the same as Input.

See Also

Input # Statement.

Example

This example uses the Input function to read one character at a time from a file and print it to the Debug window. For purposes of this example, assume that TESTFILE is a text file with a few lines of sample data.


Open "TESTFILE" For Input As #1    ' Open file.
Do While Not EOF(1)    ' Loop until end of file.
    MyChar = Input(1, #1)    ' Get one character.
    Debug.Print MyChar    ' Print to Debug window.
Loop
Close #1    ' Close file.