Results 1 to 3 of 3

Thread: [RESOLVED] aligning currency or numbers by decimal point

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2012
    Location
    Australia
    Posts
    1,172

    Resolved [RESOLVED] aligning currency or numbers by decimal point

    Using the vb6 compatability printing regime.

    Uisng simple code I'd like to align decimal ponts on quantities or currency figures so that report fields are vertically aligned eg

    1,234.56 and 40 need to be aligned so that the 40 is directly beneath the 34 The aligning of the left is easy, but not correct for quantities that may differ widely and only the decimal point is the correct reference.

    The way I did it with Vb6 was

    HTML Code:
    Aligned = Format(Amount,"#,###")
    Printer.CurrentX=125-Printer.TextWidth(Aligned)
    Printer.Print Aligned

  2. #2
    PowerPoster stanav's Avatar
    Join Date
    Jul 2006
    Location
    Providence, RI - USA
    Posts
    9,290

    Re: aligning currency or numbers by decimal point

    1. You need to use a fixed width font.
    2. You need to use String.PadLeft to make all the strings the same length
    3. In case of even numbers such as 40, you need to format it to show the decimal part too, i.e "40.00"
    Let us have faith that right makes might, and in that faith, let us, to the end, dare to do our duty as we understand it.
    - Abraham Lincoln -

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2012
    Location
    Australia
    Posts
    1,172

    Re: aligning currency or numbers by decimal point

    I've found it thanks, without using a fixed width font.

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