Share via


Visual Basic: CommonDialog Control

CommonDialog Control (Print Dialog) Example

The following example displays the Print dialog

  Private Sub Command1_Click()
  Dim BeginPage, EndPage, NumCopies, i
  ' Set Cancel to True
  CommonDialog1.CancelError = True
  On Error GoTo ErrHandler
  ' Display the Print dialog box
  CommonDialog1.ShowPrinter
  ' Get user-selected values from the dialog box
  BeginPage = CommonDialog1.FromPage
  EndPage = CommonDialog1.ToPage
  NumCopies = CommonDialog1.Copies
  For i = 1 To NumCopies
    ' Put code here to send data to the printer
  Next i
  Exit Sub
ErrHandler:
  ' User pressed the Cancel button
  Exit Sub
End Sub