Max Wanadoo
max.wanadoo at gmail.com
Wed Feb 17 13:49:28 CST 2010
Here is what I have come up with. Code is dead simple and easy. It all
centres on the Fonts being used for the List Box.
No twips or twerps.
I have a LIST BOX with 3 columns. Col 1 is text. Col2 is Credits. Col3 is
Debits.
I needed to have the currency line up as normal, right justified in cols 2
and 3.
There may be other Fonts. I would appreciate if you guys can tell me if
this font come as-is on your PCs. I have not installed it but it may have
been put on my system via other software.
DETAILS:-
Font is: Consolas (Thanks to Dan Waters for this tip)
Pitch is: 8
Text is not very good but it is readable.
BUT the numeric values line up like soldiers on parade. And that is my
aim.
These fonts also might work: BatangChe, @MS Gothic
Here is the code below.
Max
Private Function fJustifyText(ByVal Amount As Currency) As String
Dim iLen As Integer, strAmount As String, lVal As Long
lVal = Int(Abs(Amount))
strAmount = CStr(Amount)
If Abs(Amount) - Int(Abs(Amount)) = 0 Then strAmount = Int(strAmount) &
".00"
iLen = Len(strAmount)
'see if the formatting will insert any "," and allow for them to a range
I am happy with
iLen = iLen + Switch(lVal >= 1000000000, 3, lVal >= 1000000, 2, lVal >=
1000, 1, lVal >= 0, 0)
' default spacing for my list box is 12
fJustifyText = String(12 - iLen, Chr(160)) & Format(Amount, "#,##0.00")
' Chr(160) on my system is invisible and has been on all my systems to
date. YMMV
End Function