Input[$](n,[#]filenumber)
Remarks
Input returns a Variant
The Input[$] function has these parts:
Part Description
n Number of characters (bytes) to read from the file. Must be less than 65,535.
filenumber Number used in the Open statement to open the file. It can be any numeric expression that evaluates to the number of an open file.
The Input[$] function can only be used with files opened in Input or Binary mode.
Unlike the Input # statement, Input[$] returns all of the characters it reads, including commas, carriage returns, linefeeds, quotation marks, and leading spaces.
Input # Statement
Input, Input$ Functions Example
The example uses the Input function to read one character at a time from a file. When an ANSI character code 10 (linefeed) is encountered, the entire line of text is displayed in a message box. To try this example, paste the code into the Declarations section of a form. Then press F5 and click the form.
Sub Form_Click ()
Dim Char, FileName, TextData ' Declare variables.
FileName = InputBox("Enter filename.") ' Get file name.
If Len(FileName) Then
Open FileName For Input As #1 ' Open file.
Do While Not EOF(1)
Char = Input(1, #1) ' Get one character.
If Char <> Chr(10) Then ' If not linefeed.
TextData = TextData & Char
Else ' If linefeed,
MsgBox TextData ' display line.
TextData = "" ' Clear line.
End If
Loop ' Loop if not end of file.
Close # 1 ' Close file.
End If
End Sub