Visual Basic for Applications Reference
Write # Statement
Writes data to a sequential file.
Write #filenumber, [outputlist]
The Write # statement syntax has these parts:
|filenumber||Required. Any valid file number.|
|outputlist||Optional. One or more comma-delimited numeric expressions or string expressions to write to a file.|
Data written with Write # is usually read from a file with Input #.
If you omit outputlist and include a comma after filenumber, a blank line is printed to the file. Multiple expressions can be separated with a space, a semicolon, or a comma. A space has the same effect as a semicolon.
When Write # is used to write data to a file, several universal assumptions are followed so the data can always be read and correctly interpreted using Input #, regardless of locale:
Numeric data is always written using the period as the decimal separator.
If outputlist data is Null data,
#NULL#is written to the file.
For Error data, the output appears as
#ERROR errorcode#. The Error keyword is not translated, regardless of locale.
Unlike the Print # statement, the Write # statement inserts commas between items and quotation marks around strings as they are written to the file. You don't have to put explicit delimiters in the list. Write # inserts a newline character, that is, a carriage returnlinefeed (Chr(13) + Chr(10)), after it has written the final character in outputlist to the file.
*Note* You should not write strings that contain embedded quotation marks, for example,
"1,2""X" for use with the Input # statement: Input # parses this string as two complete and separate strings.