How do I format the result as money value?

0 favourites
  • 7 posts
From the Asset Store
Train your brain and become a merge master with Money Merge, the brand new jigsaw puzzle and puzzle game.
  • I believe this is easy but not for me. I'm adding up some values and I want the total to look like this: $ 1,000 instead $ 1.000

  • HA! You would think so, but it's actually been asked quite a lot of times around here.

    1st, set the function.

    'Function' > On (name your function) - 'Function' > Set return value to RegexReplace(Function.Param(0) & "", "(\d)(?=(\d{3})+$)", "g", "$&,")

    Then -

    YourTextBox > Set text to Function.Call("name your function", GlobalVariable)

    From the 1st part (name your function) will be the same as the 2nd part ("name your function"

    This will only give you the commas: i.e $1,000,000

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hey jeffige

    Thank you so much for this solution.

    I am having two issues now :

    • During the sum, I need to add a percent of the value and I need to keep this format: 1.32. For this, I am using round((variable*0.02)/100)*100 but sometime I get only 0. Other example: if I have 2985 and I use round((variable*0.05)/100)*100 I am getting 100 instead of 149.25
    • At the end I am using your instructions and I am not getting the cents (1,001.32). I believe it happens because the another issue.
  • Hey guys

    I still need a little help here.

    I have figured out part of the problem: I inverted the operators. So the right is: round((variable*percent)*100)/100

    But if the value have cents, instead of 1,001.32, I am getting 1001.32. I need to rounded the value (remove the cents) to get 1,001 but I really need to get 1,001.32

  • It was a little challenge =]

  • It was a little challenge =]

    Sorry the delay and thanks for the help.

    As I have more than 5 text objects it's better if I use a function for this, right? I will give it a try.

  • You don't need functions, you can simple filter usina the same condition of the trigger for the function

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)