Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
LPRINT, PRINT Statements Details
◄Summary► ◄Details► ◄Example► ◄Contents► ◄Index► ◄Back►
──────────────────────────────────────────────────────────────────────────────
LPRINT [USING formatstring$;] expressionlist [{; | ,}]
PRINT [USING formatstring$;] [expressionlist] [{; | ,}]
Usage Notes
■ PRINT within a form module is treated as the PRINT method rather than
the PRINT statement. See: ◄PRINT Method►
■ To use the PRINT statement form within a form module to print to the
screen or perform other PRINT statement specific functions, you must
place the PRINT statement in a general procedure and call it from the
form module. For example:
SUB Form_Click ' In form module
SCREEN.HIDE
CALL MyPrint("Hello")
SCREEN.SHOW
END SUB
SUB MyPrint (temp$) ' In another module: Test.BAS
PRINT temp$
END SUB
■ If the number to print is larger than the specified numeric field, a
percent sign (%) is printed in front of the number. If rounding causes
the number to exceed the field, a percent sign is printed in front of
the rounded number. If the number of digits specified exceeds 24, Visual
Basic generates the error message, "Illegal function call."
■ Because the LPRINT USING statement uses the LPT1 printer device, do not
use LPRINT USING in a program that also contains an OPEN "LPT1"
statement. Using these two statements together produces unpredictable
results.
■ The LPRINT USING statement functions in the same way as the PRINT USING
statement, except that output goes to the printer.
■ Printer output from an LPRINT USING statement will be the same as
screen output from a PRINT USING statement, if both statements have the
same values for formatstring$, expressionlist, and output-line width.
See: ◄Format Specifiers►
■ The LPRINT USING statement assumes an 80-character-wide printer. This
width can be changed with a WIDTH statement. See: ◄WIDTH Statement►
■ If you use LPRINT USING with no arguments, a blank line is printed.
■ Item-format rules:
• A printed number is always followed by a space.
• If the number is positive, it is also preceded by a space; if the
number is negative, it is preceded by a minus sign (-).
• If a single-precision number can be expressed as seven or fewer digits
with no loss of accuracy, then it is printed in fixed-point format;
otherwise, floating-point format is used. For example, the number
1.1E-6 is displayed as .0000011, but the number 1.1E-7 is displayed
as 1.1E-7.
• If a double-precision number can be expressed as 15 or fewer digits
and with no loss of accuracy, then it is printed in fixed-point
format; otherwise, floating-point format is used.
For example, the number 1.1D-14 is displayed as .000000000000011, but
the number 1.1D-15 is displayed as 1.1D-15.
■ Print-line format rules:
• The print line is divided into print zones of 14 spaces each.
• The position of each printed item is determined by the punctuation
used to separate the items in expressionlist:
■ A semicolon makes the next value print immediately after the last
value.
■ A comma makes the next value print at the start of the next zone.
■ Using one or more spaces or tabs between expressions has the same
effect as using a semicolon.
• If a comma or a semicolon terminates the list of expressions, the
next PRINT statement to execute prints on the same line, after spacing
accordingly.
• If expressionlist ends without a comma or a semicolon, a carriage
return-linefeed sequence is printed at the end of the line.
• If the printed line is wider than the screen width, Visual Basic goes
to the next physical line and continues printing.
■ To print information from a record, use individual record element names
in the PRINT statement. For example:
TYPE MyType
Word AS STRING * 20
Count AS LONG
END TYPE
DIM Myrec AS MyType
PRINT Myrec.Word
■ The printer output from the LPRINT statement will be the same as the
screen output from a PRINT statement if both statements have the same
expressionlist values and output-line width.
■ The LPRINT statement assumes an 80-character-wide printer. This width
can be changed with a WIDTH statement. See: ◄WIDTH Statement►
■ If you use LPRINT with no arguments, a blank line is printed.
■ An LPRINT CHR$(13) statement outputs both CHR$(13) and CHR$(10).
■ Because the LPRINT statement uses the LPT1 printer device, do not use
LPRINT in a program that also contains an OPEN "LPT1" statement. Using
these two statements together produces unpredictable results.