PRINT / ?
Source: https://www.freebasic.net/wiki/wikka.php?wakka=KeyPgPrint Last revised: 2025-09-04
Outputs a list of values to the screen.
Syntax
(Print | ?) [expressionlist] [, | ;]Parameters
- expressionlist — List of items to print.
Description
Print outputs a list of values to the screen. Numeric values are converted to their string representation, with left padding for the sign. Objects of user-defined types must overload Operator Cast () As String.
Separators:
- Comma (
,) — printing takes place at the next 14-column boundary. - Semicolon (
;) — values are printed with no space between them.
Special expressions:
Spc()— inserts spaces.Tab()— aligns printing to a specific column.
A new-line character is printed after the expression list unless the list is followed by a comma or semicolon. A Print with no expressions prints a new-line.
Note: Print resets the Err value after each expression is printed.
Note: In graphics mode, Draw String provides a flexible alternative to Print.
Examples
vb
' print "Hello World!", and a new-line
Print "Hello World!"
' print several strings on one line, then print a new-line
Print "Hello";
Print "World"; "!";
Print
' column separator
Print "Hello!", "World!"
' printing variables/expressions
Dim As Double pi = Atn(1) * 4
Dim As String s = "FreeBASIC"
Print "3 * 4 ="; 3 * 4
Print "Pi is approximately"; pi
Print s; " is great!"Dialect Differences
- In the
-lang qbdialect, an extra space is printed after any integer number.
Differences from QB
- No extra space after floating-point numbers (when using QB's variable types in
-lang qb). - Unsigned numbers are printed without a space before them.
- QB did not support casting for UDTs.