Click to See Complete Forum and Search --> : Formatting Numbers
Hutty
Dec 1st, 1999, 08:59 PM
I'm using the format function to format the numbers in a series of listboxes. However, the numbers don't align properly. It would be hard to use spaces in my code because the size of the number for each listbox could vary depending on the query. Is there a way to align the numbers from the far right space of each listbox going left?
The numbers currently look like this:
87566666
12344
0
Thanks!
carlosapv
Dec 1st, 1999, 10:23 PM
property align in listboxes
listboxes.align=left
or format(num,####0)
# represent the space at right or left depending of your selecction
------------------
carlos alberto perez vergara
carlosapv@hotmail.com
analist programming
visual basic 5.0
Lyla
Dec 2nd, 1999, 11:31 AM
Hi.
Have you tried the @ sign. (e.g.):
list1.text= format(list1.text, "##0.00","@@@@@")
You'll never find it in help! and If it works thank Serge for it. :)
Good Luck.
Aaron Young
Dec 2nd, 1999, 11:36 AM
Unfortunately the last time I looked there wasn't an Align Property for the Listbox.
However, you could change the Listbox Font to a Fixed-width Font and Align the Items using Spaces, or you could use the TextWidth Method of the Form to Calculate the No. of spaces you need to align the Proportional Default Font, eg.
Private Sub Form_Load()
Dim I As Integer
Dim sItem As String
For I = 1 To 100
sItem = Trim(Str(I))
List1.AddItem Space((List1.Width - 350 - TextWidth(sItem)) / TextWidth(" ")) & sItem
Next
End Sub
Assuming the Font for your Form matches the Font for your Listbox.
------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
adyoung@win.bright.net
[This message has been edited by Aaron Young (edited 12-02-1999).]
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.