如何强制使用格式“。”作为小数分隔符,无论本地化设置如何 [英] How to force Format to use "." as decimal separator, regardless of localization setting

查看:80
本文介绍了如何强制使用格式“。”作为小数分隔符,无论本地化设置如何的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道之前已经讨论过这个问题,但我无法将这些问题与我的问题联系起来。

I know this issue has been discussed before, but I can't relate these threads to my problem.

 

我有VBscript,必须使用"。"格式化十进制数字。 (句点)作为小数分隔符,不管当前计算机的本地化。 (它用作另一个应用程序的输入)

I have VBscript that must format decimal numbers using the "." (period) as a decimal separator, regardless of the localization of the current computer. (It is used as input to another application)

使用格式函数创建值:

  myNumberString = Format(floatValue,& ; 00.000"";

 myNumberString = Format( floatValue, "00.000");

但如果计算机本地化使用",",作为分隔符,然后格式返回我的字符串有",",分隔符。

But if computer is localized to use "," as separator, then also Format returns my string having "," separators.

 

推荐答案

您好,

这个论坛是VB.NET,您可以在本地计算机上确定当前的十进制数字(使用全球化),如果它不是"。" (点),使用点"。"格式化它。像这样:

This forum is VB.NET, and you can determine current number decimal seperator on local computer (using Globalization) then if it's not "." (dot), format it using dot "." like this:

如果Globalization.CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator<> "。"然后是
            '如果十进制分隔符是","在本地计算机上,强制使用"。"取代

           myNumberString = myNumberString.Replace(",","。")

        &NBSP;&NBSP;&NBSP; 'now" myNumberString"类似于"00.000"的东西。而不是"00,000"。

结束如果

HTH。

 


这篇关于如何强制使用格式“。”作为小数分隔符,无论本地化设置如何的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆