Results 1 to 4 of 4

Thread: Formatting Numbers

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 1999
    Posts
    153

    Post

    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!

  2. #2
    Member
    Join Date
    Nov 1999
    Location
    panama
    Posts
    57

    Post

    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
    [email protected]
    analist programming
    visual basic 5.0


  3. #3
    Addicted Member
    Join Date
    Jul 1999
    Location
    Portland, OR.
    Posts
    226

    Post

    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.

  4. #4
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    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.
    Code:
    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
    [email protected]
    [email protected]


    [This message has been edited by Aaron Young (edited 12-02-1999).]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width