Visual Basic Concepts

Visual Studio 6.0

Displaying Text on Forms and Picture Boxes

To display text on a form or picture box, use the Print method, preceded by the name of the form or picture box. To send output text to a printer, use the Print method on the Printer object.

Using the Print Method

The Print method syntax is:

[object.]Print [outputlist] [{ ; | , }]

The object argument is optional; if omitted, the Print method applies to the current form.

For example, the following statements print messages to:

  • A form named MyForm:
    MyForm.Print "This is a form."
  • A picture box named picMiniMsg:
    picMiniMsg.Print "This is a picture box."
  • The current form:
    Print "This is the current form."
  • The Printer object:
    Printer.Print "This text is going to the printer."

The outputlist argument is the text that appears on the form or picture box. Multiple items in the outputlist argument must be separated by commas or semicolons or both, as explained in "Displaying Different Items on a Single Line" later in this chapter.

Truncated Text

If the form or picture box is too small to display all the text, the text is cut off. Where the form or picture box cuts off the text depends on the coordinates of the location at which you began printing the text. You cannot scroll through a form or picture box.


When you print text to a form, the text appears in a layer behind any controls that have been placed on the form. So printing to a form usually works best on a form specifically created to hold the text. For more information about how text and graphics appear in layers on a form, see "Layering Graphics with AutoRedraw and ClipControls" later in this chapter.