Universal Windows Platform (UWP)
A Microsoft platform for building and publishing apps for Windows desktop devices.
2,524 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi Roy Li,
thanks for responding.
So...:
My app is for managing invoices. And I have this TextBox with numbers only and one comma for a price. My app rounds the price to two digits after a comma, after KEY DOWN.
So when I type a number with a comma it always recalculate and make it round.
But after entering another comma, my app crashes.
I thought about separate round button when invoice is finnished. That is the only solution I can imagine.
Is there a better way, Mr. Roy?
Is the number text something like 111,222 or 222,333? I'm confused about
My app rounds the price to two digits after a comma
. Could you please give specific example for the value input and what is the expected value you want to get?when a users types too much, like: xxx,xxxx, it needs to Number.Ceilling to xxx,xx
wait I explained it wrong.
I use double.Parse to know if it is not -1 for example so it can correct it to 0
is it enought, now, Mr. Roy Li?
Or shall I elaborate a longer explanation?
Please just give a simple example about the input value that the user type and then let me know the expected value you want to get. We shall check and try to find a way to convert it.
It would also be better if you could share some code about what you are doing now.
Are you trying to convert 123,123,12 to 123123,12?
@VoyTec Did I understand your scenario correctly?
almost.
I want to convert 12,303 to 12,30 and another comma entered in the TextBox would be deleted immediately.
Sign in to comment
Hello,
Welcome to Microsoft Q&A!
I'm not sure about the input data that you mentioned. But I have made a solution about how to clean the second comma when user type something in the
TextBox
. We could handle the TextBox.TextChanged Event and check the input value when user input every character. Then if we find that there are two commas, remove the last comma.Here is the code I use:
Thank you.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Sign in to comment
1 additional answer
Sort by: Most helpful
so are commas for 100, 1000, etc separator, or for whole and decimal?
if the former its just:
value = value.Replace(",","")
if the latter, how do you know which one is correct?
I just need to avoid app crash, cause I got double.Parse function in my app.
decimal
i want to replace Text in a TexBox with 0 when he recognize putting second comma
Sign in to comment
Activity