devxlogo

Using Format Function to Right Justify

Using Format Function to Right Justify

Question:
When using printer.print statements to send output directly to the printer, it used to be possible in QB PDS to use something like “printer.print format(number, “###,###.00”) to get right justification of numbers on successive lines. Now, although the MS documentation says that the “#” characters act as placeholders, they actually do not. How can you format numbers so that they right-justify on a printout?

Answer:
If you know how long your field is (maximum length), you can simply subtract the length of your formatted number from it. You then add that many spaces to the front of the number. That will force the string to the right.


On 3/31/00, Marty Liss responded:
This is incorrect. It is true only if you are using a fixed-width font like Courier, otherwise the leading spaces are thinner than the numbers so the justification that results from this tip is ragged.


devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist