Applies ToAccess for Microsoft 365 Access 2024 Access 2021 Access 2019 Access 2016

Note: The function, method, object, or property described in this topic is disabled if the Microsoft Jet Expression Service is running in sandbox mode, which prevents the evaluation of potentially unsafe expressions. For more information on sandbox mode, search for "sandbox mode" in Help.

Returns String containing characters from a file opened in Input or Binary mode.

Syntax

Input( number, [# ] filenumber)

The Input function syntax has these arguments:

Argument

Description

number

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

filenumber

Required. Any valid file number.

Remarks

Data read with the Input function is usually written to a file with Print # or Put. 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.

With files opened for Binary access, an attempt to read through the file using the Input function until EOF returns True generates an error. Use the LOF and Loc functions instead of EOF when reading binary files with Input, or use Get when using the EOF function.

Note:  Use the InputB function for byte data contained within text files. With InputB, number specifies the number of bytes to return rather than the number of characters to return.

Example

Note: Examples that follow demonstrate the use of this function in a Visual Basic for Applications (VBA) module. For more information about working with VBA, select Developer Reference in the drop-down list next to Search and enter one or more terms in the search box.

This example uses the Input function to read one character at a time from a file and print it to the Immediate window. This example assumes that TESTFILE is a text file with a few lines of sample data.

Dim MyCharOpen "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 the Immediate window.LoopClose #1    ' Close file.

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.