B4J Question Comma in Thousands e.g. £1,000.00?

Discussion in 'B4J Questions' started by ElliotHC, Jul 25, 2019.

  1. ElliotHC

    ElliotHC Active Member Licensed User

    I need to add a comma in a label value when above 999, is this easy to do?
     
  2. rboeck

    rboeck Well-Known Member Licensed User

    Just search for NumberFormat and NumberFormat2.
     
  3. José J. Aguilar

    José J. Aguilar Active Member Licensed User

  4. ElliotHC

    ElliotHC Active Member Licensed User

    From the help, NumberFormat2 returns a String.
    - 0 -> MinimumIntegers
    - 3 -> MaximumFractions
    - 2 -> MinimumFractions
    - True -> GroupingUsed
    Examples:
    MyNumber Result
    12.123456 12.123
    12345.1 12,345.10
    0.12 .12
     
  5. DonManfred

    DonManfred Expert Licensed User

  6. Sandman

    Sandman Well-Known Member Licensed User

    Somewhat relevant article:

    Falsehoods programmers believe about prices
    https://gist.github.com/rgs/6509585

    (Not all regions separate thousands with a comma. So if your app targets more than the users that do that, you might want to use a smarter solution.)
     
  7. Erel

    Erel Administrator Staff Member Licensed User

    Please post a few numbers as an example of the format you are looking for.
     
  8. ElliotHC

    ElliotHC Active Member Licensed User

    I had 'False' when I needed 'True' in NumberFormat2.
     
  9. OliverA

    OliverA Well-Known Member Licensed User

    The solution pointed to by @José J. Aguilar takes these issues into account. Now if you also want to display the appropriate currency symbol, then the article linked to in the provided solution gives the appropriate information.
     
    José J. Aguilar likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice