vc++ 格式化数字成3位3位显示
程序员文章站
2022-06-08 09:54:24
...
如题
以下代码未测试通过:
CultureInfo^ MyCI = gcnew CultureInfo( "en-US",false ); NumberFormatInfo^ nfi = MyCI->NumberFormat; // nfi->CurrencyDecimalDigits = 0; nfi->NumberDecimalDigits = 0; // Displays a value with the default separator (S"."). Int64 myInt = 12345678; nfi->CurrencyDecimalSeparator = ","; this->TB_Show->Text = myInt.ToString( "N", nfi ) ;
以下代码未测试通过:
String^ str = gcnew String("12345"); String^ res; CultureInfo^ MyCI = gcnew CultureInfo( "en-US",false ); NumberFormatInfo^ nfi = MyCI->NumberFormat; nfi->CurrencyDecimalDigits = 0; nfi->CurrencyDecimalSeparator = ","; res = String::Format("###,#",str);