Returns characters from an open sequential or binary file.
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. |
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 byte data contained within text files. Instead of specifying the number of characters to return, number specifies the number of bytes.
Input # Statement.
This example uses the Input function to read one character at a time from a file and print it to the Debug window. This example assumes that TESTFILE is a text file with a few lines of sample data.
Open "TESTFILE" For Input As #1 ' Open file.While Not EOF(1) ' Loop until end of file. MyChar = Input(1, #1) ' Get one character. Debug.Print MyChar ' Print to Debug window.#1 ' Close file.