Input, Input$, InputB, InputB$ (functions)

Syntax

Input[$](numchars,[#]filenumber)

InputB[$](numbytes,[#]filenumber)

Description

Returns a specified number of characters or bytes read from a given sequential file.

Comments

The functions return the following.

 

Functions

Return

 

Input$ and InputB$

String

 

Input and InputB

String variant.

 

The following parameters are required:

 

Parameter

Description

 

numchars

Integer containing the number of characters to be read from the file.

 

numbytes

Integer containing the number of bytes to be read from the file.

 

filenumber

Integer referencing a file opened in either Input or Binary mode. This is the same number passed to the Open statement.

 

Functions are used to read the following.

 

Functions

Used to read:

 

InputB and InputB$

Byte data from a file.

 

Input and Input$

All characters, including spaces and end-of-lines. Null characters are ignored.

Example

'This example opens the autoexec.bat file and displays it in a

'dialog box.

Const crlf = Chr$(13) & Chr$(10)

Sub Main()

    x& = FileLen("c:\autoexec.bat")

    If x& > 0 Then

     Open "c:\autoexec.bat" For Input As #1

    Else

     MsgBox "File not found or empty."

     Exit Sub

    End If

    If x& > 80 Then

     ins = Input(80,#1)

    Else

     ins = Input(x,#1)

    End If

    Close

    MsgBox "File length: " & x& & crlf & ins

End Sub

See Also

Open (statement); Get (statement); Input# (statement); Line Input# (statement).

 

 

 

 

More information

I