textBox中的3位数字 [英] seperate 3 digits in textBox
问题描述
你好
我有一个textBox可以输入整数值,例如金钱成本.
我想用camma(,)将数字从右到左分开.
例如:(12,250,000)
我使用此代码:
Hello
i have a textBox to enter integer value to it for example cost of money.
i want to seperate digits from right to left with camma(,).
for example:(12,250,000)
i use this code:
textbox1.text=decimal.parse(textbox1.text).Tostring("#,#");
但是我在第一个camma之后不能输入零,并且它将显示错误(输入字符串格式不正确)
请帮助
but i can not enter zero after the first camma.and it will show error(input string was not in a correct format)
please help
推荐答案
如果您想要货币格式,这很容易:
Well this is easy if you want currency format:
textbox1.text=decimal.parse(textbox1.text).Tostring("C");
或没有货币符号:
or without the currency sign:
textbox1.text=decimal.parse(textbox1.text).ToString("0,0.0", CultureInfo.InvariantCulture);
快速格式列表显示在文档中:
http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx [ ^ ]
或者您可以自定义格式字符串:
http://msdn.microsoft.com/en-us/library/0c899ak8.aspx [ ^ ]
A list of quick formats are shown in the documentation:
http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx[^]
or you can custom format the string:
http://msdn.microsoft.com/en-us/library/0c899ak8.aspx[^]
您好,
您应该使用javascript.请参考以下链接:
5个缺少的Javascript数字格式功能 [使用(逗号等)将数字格式设置为货币 [货币格式,将逗号放入数字:JavaScript和Perl [使用JavaScript格式化货币 [使用javascript设置货币格式 [ JavaScript货币转换脚本 [
Hi,
You should use javascript. Refer the link below:
5 Missing Javascript Number Format Functions[^]
Formatting number to currency with the (commas etc)[^]
Currency Formatting, Putting Commas In Numbers: JavaScript and Perl[^]
Formatting Currency with JavaScript[^]
Format currency using javascript[^]
A JavaScript Currency Conversion Script[^]
--Amit
尝试..对于给定的输入
try it..for your given input
Regex.Match(textbox1.Text,@"^[0-9]\d{2},[0-9]\d{3},[0-9]\d{3}
这篇关于textBox中的3位数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!