Statements for reading and writing

VBA provides several statements to read and write data to a file.

Three statements are used for reading data from a sequential access file:

♦ Input: Reads a specified number of characters from a file

♦ Input #: Reads data as a series of variables, with variables separated by a comma

♦ Line Input #: Reads a complete line of data (delineated by a carriage return and/or linefeed character)

Two statements are used for writing data to a sequential access file:

♦ Write #: Writes a series of values, with each value separated by a comma and enclosed in quotes. If you end the statement with a semicolon, a carriage return/linefeed sequence is not inserted after each value. Data written with Write # is usually read from a file with an Input # statement.

♦ Print #: Writes a series of values, with each value separated by a Tab character. If you end the statement with a semicolon, a carriage return/ linefeed sequence is not inserted after each value. Data written with Print # is usually read from a file with a Line Input # or an Input statement.

0 0

Post a comment