区域设置小数点分隔符在 VB.net 和 ArcGis 10.1 中不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17601742/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Regional settings decimal separator not working in VB.net and ArcGis 10.1
提问by Math
I am developping an application to be used with ArcGis ArcMap 10 and 10.1. My application is a dll that I add to Arcmap (it is a toolbar). When I am debugging on my machine, it is working fine (Windows server 2003 and ArcGis 10). But on another machine which is a Windows server 2008 with ArcGis 10.1, the decimal separator becomes a comma (,) instead of a point (.) when converting double value to string. If I convert a double variable to string, using cstr(variable) or text = variable, or text=variable.tostring, I always get a comma instead of a point.
我正在开发一个与 ArcGis ArcMap 10 和 10.1 一起使用的应用程序。我的应用程序是我添加到 Arcmap 的 dll(它是一个工具栏)。当我在我的机器上调试时,它工作正常(Windows server 2003 和 ArcGis 10)。但在另一台装有 ArcGis 10.1 的 Windows Server 2008 机器上,将双精度值转换为字符串时,小数点分隔符变为逗号 (,) 而不是点 (.)。如果我使用 cstr(variable) 或 text = variable 或 text=variable.tostring 将双变量转换为字符串,我总是得到一个逗号而不是一个点。
The regional settings are correct on both machines. I tried to set the culture with the following code and I get a "instance is read-only" error. But I don't get this error on the ArcGis 10 machine.
两台机器上的区域设置都是正确的。我尝试使用以下代码设置区域性,但收到“实例为只读”错误。但是我在 ArcGis 10 机器上没有收到这个错误。
My.Application.Culture.NumberFormat.NumberDecimalSeparator = "."
System.Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.CurrencySymbol = "."
Strangely enough, when I look at numbers in ArcGis 10.1, the separator is the point. So the problem seems to be in my application dll.
奇怪的是,当我查看 ArcGis 10.1 中的数字时,分隔符才是重点。所以问题似乎出在我的应用程序 dll 中。
Can someone help me?
有人能帮我吗?
回答by David -
Try the following code
试试下面的代码
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Application.CurrentCulture = New CultureInfo("EN-US")
End Sub

