- Home /
Label dots in between numbers (currency formatting)
I couldn't make up a better name for the question. I've got a label which shows a variable representing your current money. The things is, the amount of money you have can be immense. Is there a way (in script) to show the variable with dots between the 'thousands'. Once again, not a very clear description. I'm trying to figure how to do this:
$2.500.000,-
Instead of this:
$2500000,-
Is there a way to do this?
Answer by aldonaletto · May 24, 2012 at 02:38 PM
This is currency formatting. You can format values as currency in .NET with String.Format("{0:C}", value):
var money: float = 2500000;
print(String.Format("{0:C}", money);
And how would I implement that in this code?
GUI.Label (Rect (20, Screen.height - 433, 300, 75), "$$anonymous$$oney: $" + main.Current$$anonymous$$oney + ",-");
.... "$$anonymous$$oney: " + String.Format("{0:C}", main.Current$$anonymous$$oney) + ",-") ;
Just remember that {0:C} is going to show Euros in Europe (for now at least:), £ in the U$$anonymous$$, $ in the US etc.
actually this doesn't show £ in the U$$anonymous$$!!!
Answer by whydoidoit · May 24, 2012 at 02:38 PM
When you put the text into the label just use String.Format("{0:C}", yourNumberHere) for your local currency or String.Format("${0:#,0}", yourNumberHere) for one that always starts with a dollar - it should format according to the locale of the device using "." and "," relative to how the user expects to see it.
Your answer
Follow this Question
Related Questions
variables as GUI 1 Answer
String + Variable to retrieve a variable? 2 Answers
Edit Variables From Game! 1 Answer
Make user change variable only by specific number 1 Answer
Input Field Text string to string variable. (const string) 0 Answers