Print Method

Applies To

Debug Object.

Description

Prints text in the Immediate pane of the Debug window.

Syntax

[object.]Print [outputlist]

The Print method syntax has these parts:

Part

Description

object

Object expression that evaluates to the Debug object.

outputlist

Expression or list of expressions to print. If omitted, a blank line is printed.


The outputlist argument has the following syntax and parts:

[{Spc(n) | Tab[(n)]}][expression][charpos]

Part

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 at 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 or string expressions to print.

charpos

Specifies the insertion point for the next character. Use a semicolon to specify the insertion point to immediately follow the last character displayed. Use Tab(n) to position the insertion point at 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.


Remarks

Multiple expressions can be separated with either a space or a semicolon. A space has the same effect as a semicolon.

All data printed to the Immediate pane is internationally aware; that is, the data is properly formatted (using the appropriate decimal separator) and the keywords are output in the language appropriate for the international locale specified for your system.

For Boolean data, either True or False is printed. The True and False keywords are translated, as appropriate, according to the locale setting specified for your system.

Date data is written using the standard short date format recognized by your system. When either the date or the time component is missing or zero, only the data provided gets written.

Nothing is written if outputlist data is Empty. However, if outputlist data is Null, Null is output. Again, the Null keyword is translated, as appropriate, when output.

For error data, the output appears as Error errorcode. The Error keyword is translated, as appropriate, when output.

Note

Because the Print method normally prints with proportionally-spaced characters, it is important to remember that there is no correlation between the number of characters printed and the number of fixed-width columns those characters occupy. For example, a wide letter, such as a "W", occupies more than one fixed-width column, whereas a narrow letter, such as an "i", occupies less. To account for cases where wider than average characters are used, you must ensure that your tabular columns are positioned far enough apart. Alternatively, you can print using a fixed-pitch font (such as Courier) to ensure that each character uses only one column.

See Also

Debug Object, Print # Statement, Spc Function, Tab Function.

Example

This example uses the Print method to output text to the Debug object; that is, display text in the Debug window.


For I = 11 To 20    ' Loop 10 times.
    ' Print each value on a new line.
    Debug.Print I
Next I

For I = 11 To 20    ' Loop 10 times.
    ' Print values on the same line, next to each other.
    Debug.Print I;    
Next I
Debug.Print Spc(10) ; "Hello there"    ' Print 10 spaces before.
Debug.Print Tab(20) ; "This is a test"    ' Print at column 20.
Debug.Print "Hello"; Tab; Tab; "There"    ' Print 2 print zones apart.