CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9
  1. #1
    Join Date
    Oct 2000
    Location
    Upstate NY
    Posts
    249

    Formatting a number

    I would like to format a numerical total for display in a textBox or Label the way one used to be able to do it in Basic using (Print Using).
    As an example the number 1555333. should be shown as 1,555,333. This formatting should apply to any number submitted to the display and therefore cannot hard coded.
    Thnx&73 RSH


  2. #2
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: Formatting a number

    The format function can do this for you. The decimal seperator (in this case comma, but might as well be point) will be looked up in the system settings.

    Text1.Text = Format(52557859.4, "##,##0.00") ' 52.557.859,40




    Tom Cannaerts
    [email protected]

    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

  3. #3
    Join Date
    Oct 2000
    Location
    Upstate NY
    Posts
    249

    Re: Formatting a number

    Thanks Tom:
    Just what I needed but had overlooked in my massive quantity of literature. Works perfectly.

    73 RSH


  4. #4
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: Formatting a number

    So why you rated Cakkie answer 0-wrong/out of topic??

    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
    and all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

    The Rater
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  5. #5
    Join Date
    Oct 2000
    Location
    Upstate NY
    Posts
    249

    Re: Formatting a number

    Inadvertantly neglected to pull down the excellent rating so you came up with the zero.
    You can put at least a 1 in front of that.
    Sorry for the error.
    73 RSH


  6. #6
    Join Date
    Oct 2000
    Location
    Upstate NY
    Posts
    249

    Re: Formatting a number

    Cimperiali:
    See the answer to your question above. It was a typing error which I am not allowed to reverse.
    Sorry 'Bout that.
    73 RSH


  7. #7
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Ok,ok...

    I've seen "a lot" of zeros, today, so I was a bit nervous. I will take the suggestment once a nasty ones gave me, and take a "chill pil"
    ;-)
    Have a nice day

    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
    and all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

    The Rater
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  8. #8
    Join Date
    Jan 2000
    Location
    Olen, Belgium
    Posts
    2,477

    Re: Ok,ok...

    Never mind, doesn't affect my score, I know he appriciates my post, so i get my satisfaction. Besides, I reported the problem to Brad yesterday, he will figure it out.

    Tom Cannaerts
    [email protected]

    Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to produce bigger and better idiots. So far, the universe is winning -- Rich Cook
    Tom Cannaerts
    email: [email protected]
    www.tom.be (dutch site)

  9. #9
    Join Date
    Oct 2000
    Location
    Upstate NY
    Posts
    249

    Re: Ok,ok...

    Maybe it would be good if the (Rate it) button didnt become visible until after the selection was made.
    73 RSH


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

Featured