Results 1 to 3 of 3

Thread: Aligning text using Printer.print

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2005
    Posts
    23

    Aligning text using Printer.print

    Good day

    I would like to write a code which will aprropriately align text under each heading. For example I have columns Name, Surname and Comments, when the text is long it is not correctly aligned. The program prints a report with user names and their comments. This is the code I have :

    Printer.Print "Author"; Spc(30); "Name"; Spc(30); "Notes" - print headings and underline them

    Printer.Print "---------"; Spc(30); "--------"; Spc(30); "--------"

    For i = 1 To mLngNumOfNotes

    ' Print Notes

    Printer.Print Name(i); Spc(28); Surname(i); Spc(15); Comment(i)
    Printer.Print 'Print empty line

    Next i

    Thank you

  2. #2
    New Member
    Join Date
    Apr 2008
    Location
    UK
    Posts
    4

    Re: Aligning text using Printer.print

    I have used the following to allign currency

    tmpL=len(stringX)
    printer.print tab(100-tmpL);stringX

    usually works quite well.
    Maybe someone will give a better work around.

  3. #3
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Aligning text using Printer.print

    If you want real alignment you must print by setting the .CurrentX and .CurrentY.

    Then you also have access to Printer.TextWidth() that will tell you how "large" something is so you can do real left and right alignment of your print.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width