This article was previously published under Q325330
This article has been archived. It is offered "as is" and will no longer be updated.
Numeric values do not parse correctly in Visual Basic .NET (and in Visual C# .NET) when you use Swedish language settings.
A supported hotfix is now available from Microsoft, but it is only intended to correct the problem that is described in this article. Only apply it to systems that are experiencing this specific problem. This hotfix may receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next .NET Framework service pack that contains this hotfix.
To resolve this problem immediately, contact Microsoft Product Support Services to obtain the hotfix. For a complete list of Microsoft Product Support Services telephone numbers and information about support costs, visit the following Microsoft Web site:
Note In special cases, charges that are ordinarily incurred for support calls may be canceled if a Microsoft Support Professional determines that a specific update will resolve your problem. The usual support costs will apply to additional support questions and issues that do not qualify for the specific update in question.Important This fix requires .NET Framework SP1. This fix will not install on top of .NET Framework SP2
The English version of this fix has the file attributes (or later) that are listed in the following table. The dates and times for these files are listed in coordinated universal time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time tool in Control Panel.
Date Time Version Size File name -------------------------------------------------------------- 02-Jul-2002 22:48 1.0.3705.293 65,536 Corperfmonext.dll 03-Jul-2002 13:24 1.0.3705.293 1,953,792 Mscorlib.dll 02-Jul-2002 22:47 1.0.3705.293 2,265,088 Mscorsvr.dll 02-Jul-2002 22:40 10,256 Mscorlib.ldo 02-Jul-2002 22:47 1.0.3705.293 2,265,088 Mscorwks.dll
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.
Some conversion functions in Visual Basic .NET (such as conversion from String to Double) do not work correctly when you use Swedish language settings. The same behavior occurs when you use NumberStyles.Any in Visual C# .NET.
The following code fails in Visual Basic .NET:
d = CDbl("123 456")d = IsNumeric("123 456")MySub("123 456")Sub MySub(ByVal test As Double) ....End Sub
System.Globalization.NumberStyles.Any fails in Visual C# .NET:
d = Double.Parse("124 456",System.Globalization.NumberStyles.Any);
The following code works correctly in Visual C# .NET:
d = Double.Parse("124 456");
Steps to Reproduce the Behavior
Create a simple Visual Basic .NET Windows Form, and then put the following sample code in the event procedure of two buttons:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim d As Double Try d = CDbl("123 456") MsgBox(d) Catch Ex As Exception MsgBox(Ex.ToString) End Try End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim d As Double Try d = IsNumeric("123 456") MsgBox(d) Catch Ex As Exception MsgBox(Ex.ToString) End Try End Sub
Change your language settings to Swedish, run the program, and then click the buttons.