This week's giveaway is in the Spring forum.
We're giving away four 3 month subscriptions to Marco Behler Videos and have Marco Behler on-line!
See this thread for details.
Win a 3 month subscription to Marco Behler Videos this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

displaying decimal numbers  RSS feed

 
H.A.N. Schultz
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to show decimal numbers in columns with the decimal points
aligned. I can format the numbers to 2 decimal places but using
tabs to align the columns they are always left justified and I
need to show them with right justification. I thought FieldPosition
would do it but I can't figure out how to use it.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know if there's anything in the API, but try this (for fonts like courier)
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you can get by with a little less arithmetic:

If you want to generalize this to a reusable routine, you can't always have a pad string of the right number of blanks. This might be worth while:

I left out some details ... what if aPadWith is more than one character long? Would that be useful? Could your string wind up too long? Could we get more efficient than concatenating strings in a loop? I leave these questions to entertain you late into the coding night
[ October 06, 2003: Message edited by: Stan James ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!