Writes raw data to a sequential file.
Write #filenumber, [outputlist]
The Write statement syntax has these parts:
Part |
Description |
filenumber |
Any valid file number. |
outputlist |
One or more comma-delimited numeric or string expressions to write to a file. |
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:
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 return (Chr(13)) or carriage return-linefeed (Chr(13) + Chr (10)), after it has written the final character in outputlist to the file.
Input # Statement, Open Statement, Print # Statement.
This example uses the Write # statement to write raw data to a sequential file.
Open "TESTFILE" For Output As #1 ' Open file for output.#1, "Hello World", 234 ' Write comma delimited data.#1, ' Write blank line. ' Assign Boolean, Date, Null, and Error values.= False : MyDate = #February 12, 1969# : MyNull = Null= CVErr(32767) ' Boolean data is written as #TRUE# or #FALSE#. Date literals are ' written in universal date format, for example, #1994-07-13# ' represents July 13, 1994. Null data is written as #NULL#. ' Error data is written as #ERROR errorcode#.#1, MyBool ; " is a Boolean value"#1, MyDate ; " is a date"#1, MyNull ; " is a null value"#1, MyError ; " is an error value"#1 ' Close file.