borderAndreaVB free resources for Visual Basic developersborder

AndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2012 Andrea Tincani
:: Print a Text with a specific alignment (left, Right or Center)

Author  

Andrea Tincani

Language  

VB5, VB6

Operating Systems  

Windows 95, 98 and NT
Module

Public Sub PrintAlignedText(s As String, Alignment As AlignmentConstants)
    Select Case Alignment
    Case vbCenter
        Printer.CurrentX = (Printer.ScaleWidth - Printer.TextWidth(s)) \ 2
    Case vbLeftJustify
        Printer.CurrentX = 0
    Case vbRightJustify
        Printer.CurrentX = Printer.ScaleWidth - Printer.TextWidth(s)
    End Select
    Printer.Print s
End Sub

Usage

PrintAlignedText "Centered Text", vbCenter

:: Navigation

Home

Printing Using Visual Basic

Previous Tip

Next Tip

:: Search this site
Google
:: Related Topics
icon 14-03-2011 Word Text in an Access Table's field by irfanfazli
icon 15-02-2011 How to Add a Formula for Excel by Daisy09
icon 07-02-2011 Printer object alternative using API by vercan
icon 28-10-2010 WHAT is wrong with this "NO" by Longliverock
icon 15-01-2010 Re: Database Saving by GeoffS
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2012 Andrea Tincaniborder