Writes display-formatted data to a sequential file.
Print #filenumber, [outputlist] |
The Print # statement syntax has the following parts:
Part | Description |
filenumber | Required. Any valid file number. |
outputlist | Optional. Expression or list of expressions to print. |
Below are the valid outputlist argument settings:
[{Spc(n) | Tab[(n)]}] [expression] [charpos]
Setting | Description |
Spc(n) | Used to insert space characters in the output, where n is the number of space characters to insert. |
Tab(n) | Used to position the insertion point to an absolute column number, where n is the column number. Use Tab with no argument to position the insertion point at the beginning of the next print zone. |
expression | Numeric expressions or string expressions to print. |
charpos | Specifies the insertion point for the next character. Use a semicolon to position the insertion point immediately after the last character displayed. Use Tab(n) to position the insertion point to an absolute column number. Use Tab with no argument to position the insertion point at the beginning of the next print zone. If charpos is omitted, the next character is printed on the next line. |
Data written with Print # is usually read from a file with Line
Input # or Input.
If you omit outputlist and include only a list separator after filenumber,
a blank line is printed to the file. Multiple expressions can be separated with
either a space or a semicolon. A space has the same effect as a semicolon.
For Boolean data, either True or False is printed. The
True and False keywords are not translated, regardless of the
locale settings.
Date data is written to the file using the standard short date format
recognized by your system. When either the date or time component is missing
or zero, only the part provided gets written to the file.
Nothing is written to the file if outputlist data is Empty. However,
if outputlist data is Null, the Null keyword is written
to file.
All data written to the file using Print # is internationally aware;
that is, the data is properly formatted using the appropriate decimal separator.
Because Print # writes an image of the data to the file, you must delimit
the data so it prints correctly. If you use Tab with no arguments to
move the print position to the next print zone, Print # also writes spaces
between print fields to the file.
Note: If, at some future time, you want to read the data from a file using the Input # statement, use the Write # statement instead of the Print # statement to write the data to the file. Using Write # ensures the integrity of each separate data field by properly delimiting it, so it can be read back in using the Input # statement. Using Write # also ensures it can be correctly read in any locale.
Open "TESTFILE" For Output As #1 ' Opens file for writing. Print #1, "Example" ' Prints text to file. Print #1, ' Prints a blank line to file. Print #1, "Zone 1"; Tab; "Zone 2" ' Prints in two print zones. Print #1, "Example"; " "; "for all" ' Lines are separated with a space. Print #1, Spc(5); "5 Space" ' Prints five spaces. Print #1, Tab(10); "Hello" ' Prints a word in column 10. ' Assigns Boolean, Date values. Dim MyBool, MyDate, MyNull MyBool = False |
See Also |
Writing Data in a File, Open Statement , Write # Statement, Spc Function , Tab Function |