Since everyone is tossing in their solution to this type problem, I thought I'd add in mine:
'LogBack% function test bed for _printstring command
dpos% = 400 'we'll line up our decimal points at x=400
'ledger lines
c& = &H7F7F7F7F * (ln% = 0) - &H3F7F007F * (ln% <> 0)
Line (400 + (ln%
* 8), 0)-(400 + (ln%
* 8), _Height - 1), c&
'&H7F7F7F7F
'print the number list in columnar fashion
a$ = formatMoney(a##, 4) 'a max of 4 decimal places for my money
Data -1000000.0001,-1000000,-999999.999,-999999,-10000,-1000,-50,-10,-5.678,-1,0 Data 1,4.912,23,99.999,4587.23,12000,999999,1000000,1000001
Function formatMoney$
(money##
, maxLength
) If d
= 0 Then m$
= m$
+ "." 'add a decimal if none exists formatMoney$
= m$
+ String$(maxLength
- d
, "0") 'add the necessary number of periods
Since this is a "million dollar accountant's" problem, I thought it might be best to simply add in the sufficient number of zeros to the end of the money. Personally, nothing gets me as distracted when working with numbers, as trying to sort out which figures go with which column or row, and misaligned formatting is one of those things that has my OCD twitching constantly. Even though there's nothing in the world wrong with everyone else's solution, somehow I find my mind and attention always being drawn to that lone -5.678 which has numbers hanging off to the right side there, with none of the other values around it having any.
With everything displaying their zeroes properly, nothing stands out as taking precedence on the right side of the line, which makes it easier to find and focus on the truly important things -- which stands out the most on the left side of the line. (Also known as. "What's the greatest expense and greatest source of income!")
Maybe it's just me, but I'd rather have those trailing zeroes when dealing with accountant stuff, rather than not have them. ;)