Input # Statement

Syntax

Input #filenumber, varlist


filenumber

Use: Required

Data Type: Integer

Any valid file number.


varlist

Use: Required

Data Type: Any

Comma-delimited list of variables or user-defined types.

Description

Reads delimited data from a sequential file opened in input or binary mode.

Rules at a Glance

  • Use Input# only with files opened in input or binary modes.

  • Variables in varlist can't be array or object variables.

  • Both the type and position of data items in the file must match the variables in varlist.

  • If Input# expects to find a numeric value based on the type of a variable in varlist, and the data in the file isn't numeric, the variable is assigned a zero value. When reading the value of a variable, the function won't perform any data conversion. This means, for example, that if your program reads the string "10" and assigns it to a long integer variable named lngVar, the value of lngVar is 0.

  • Input# strips off quotation marks ("") it finds around strings.

  • After Input# reads varlist, it advances the file pointer to the first unread variable or, if the file contains no additional delimited data, to the end of the file.

  • If the end of the file is reached during an Input#, an error is generated.

  • Input# assigns string and numeric data to the relevant variable in varlist without modification; however, other types of data can be modified as shown in the following table.

Data Value Assigned to Variable
Delimiting comma or blank line Empty
#NULL#

Null
#TRUE# or #FALSE# True or False
#yyyy-mm-dd hh:mm:ss#

Date and/or time
#ERROR errornumber#

Error number (variable is a variant of subtype error)

Programming Tips and Gotchas

  • Use the EOF function to check that the end of the file has or hasn't been reached.

  • You should use the Write# statement to write data to a file, since Write# delimits data fields correctly. This insures that the data can be read correctly with the Input# statement.

See Also

Input, InputB, Input$, InputB$ Functions; Write# Statement
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.222.121.79