VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   1920
   ClientLeft      =   165
   ClientTop       =   450
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   ScaleHeight     =   1920
   ScaleWidth      =   4680
   StartUpPosition =   3  '窗口缺省
   Begin VB.CommandButton Command2 
      Caption         =   "打印"
      Height          =   435
      Left            =   3420
      TabIndex        =   2
      Top             =   780
      Width           =   1215
   End
   Begin VB.TextBox Text1 
      Height          =   1635
      Left            =   0
      TabIndex        =   1
      Text            =   "Text1"
      Top             =   120
      Width           =   3315
   End
   Begin VB.CommandButton Command1 
      Caption         =   "字体"
      Height          =   495
      Left            =   3420
      TabIndex        =   0
      Top             =   1320
      Width           =   1215
   End
   Begin MSComDlg.CommonDialog CommonDialog1 
      Left            =   3780
      Top             =   120
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
      Filter          =   "文本文件 | *.Txt"
      Flags           =   3
      FontBold        =   -1  'True
      FontItalic      =   -1  'True
      FontStrikeThru  =   -1  'True
      FontUnderLine   =   -1  'True
      InitDir         =   "C:\Windows"
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private Sub Command1_Click()
    On Error Resume Next
    CommonDialog1.Flags = cdlCFBoth Or cdlCFEffects         ' 设置Flags，见表表1.8.2
    CommonDialog1.ShowFont
    Text1.FontName = CommonDialog1.FontName
    Text1.FontSize = CommonDialog1.FontSize
    Text1.FontBold = CommonDialog1.FontBold
    Text1.FontItalic = CommonDialog1.FontItalic
    Text1.FontStrikethru = CommonDialog1.FontStrikethru
    Text1.FontUnderline = CommonDialog1.FontUnderline
    Text1.ForeColor = CommonDialog1.Color
End Sub

Private Sub Command2_Click()
    CommonDialog1.ShowPrinter                    ' 打开打印机对话框
    For i = 1 To CommonDialog1.Copies
    Printer.Print Text1.Text                    ' 打印文本框中的内容
    Next i
    Printer.EndDoc                              ' 结束文档打印
End Sub
