home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 4 Unleashed / Visual_Basic_4_Unleashed_SAMS_Publishing_1995.iso / source / chap12 / ctr-text.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-10-09  |  1.0 KB  |  35 lines

  1. VERSION 4.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "Form1"
  4.    ClientHeight    =   8460
  5.    ClientLeft      =   1140
  6.    ClientTop       =   1515
  7.    ClientWidth     =   6690
  8.    Height          =   8895
  9.    Left            =   1080
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   8460
  12.    ScaleWidth      =   6690
  13.    Top             =   1140
  14.    Width           =   6810
  15. Attribute VB_Name = "Form1"
  16. Attribute VB_Creatable = False
  17. Attribute VB_Exposed = False
  18. Option Explicit
  19. Private Sub centerText(h As Integer, str As String)
  20.     Dim pageMiddle As Integer
  21.     pageMiddle = Printer.ScaleWidth / 2
  22.     Printer.CurrentX = pageMiddle - (Printer.TextWidth(str) / 2)
  23.     Printer.CurrentY = h
  24.     Printer.Print str
  25. End Sub
  26. Private Sub Form_Click()
  27.     ' Some Printers don't support copies
  28.     On Error Resume Next
  29.     Printer.Copies = 1
  30.     On Error GoTo 0
  31.     centerText 1440, "This text is centered."
  32.     centerText 2880, "This text is centered also."
  33.     Printer.EndDoc
  34. End Sub
  35.