字符串到dbl或dec不在Server2012上工作 [英] String to dbl or dec not working on Server2012
问题描述
我们有一个winapp在Windows 7/8和除服务器2012之外的所有以前的服务器上100%工作。
适用于Win7而不是server2012的代码:
如果 aFld.Extract( 11 )。StringValue< 0 然后
lblAvailCrW.ForeColor = Color.Red
lblAvailCrT.ForeColor = Color .Red
结束 如果
我尝试转换aFld.Extract(11).StringValue以便可以将其与0进行比较以查看是否更小:
每次ivalue都有合适的类型。
Double .TryParse(aFld.Extract( 11 ).StringValue,iValue)
CDbl (aFld.Extract( 11 )。 StringValue)
十进制 .TryParse(aFld.Extract( 11 )。StringValue,iValue)
Convert.ToDouble(aFld.Extract( 11 )。StringValue)
Convert.ToDecimal(aFld.Extract( 11 )。StringValue)
aFld.Extract(11).StringValue以字符串形式返回182.25。
如果我进入屏幕,它会在转换时出现错误的格式错误。
我尝试了各种类型的转换和转换以及解析到十进制和双倍我能想到,但仍然得到相同的错误,它只是在Server 2012(不是核心版本)
任何请帮助和thanx
dim svalue as string = 182.82
' 在此处进行转换
if System.Convert.ToDecimal(svalue)< 0 然后
' < span class =code-comment>更改网格颜色
结束 如果
这是C#但是有效。
double dvalue;
string svalue = 182.82跨度>;
bool br = Double .TryParse(svalue, out dvalue);
为什么不显示你正在使用的完全代码。
< blockquote>我认为您的服务器上的区域设置是不同的。您需要解析没有特定文化的数字:
Dim number 作为 Double
number = Double .Parse(
aFld.Extract( 11 )。StringValue,
System.Globalization.NumberStyles.Number,
System.Globalization.CultureInfo.InvariantCulture)
如果数字< 0 然后
...
We have a winapp that works 100% on windows 7/8 and all the previous servers except server 2012.
The code that works on Win7 and not server2012:
If aFld.Extract(11).StringValue < 0 Then
lblAvailCrW.ForeColor = Color.Red
lblAvailCrT.ForeColor = Color.Red
End If
Things I've tried to convert the aFld.Extract(11).StringValue so that it can be compared to 0 to see if smaller:
ivalue each time has the appropriate type.
Double.TryParse(aFld.Extract(11).StringValue, iValue)
CDbl(aFld.Extract(11).StringValue)
Decimal.TryParse(aFld.Extract(11).StringValue, iValue)
Convert.ToDouble(aFld.Extract(11).StringValue)
Convert.ToDecimal(aFld.Extract(11).StringValue)
aFld.Extract(11).StringValue returns "182.25" as a string.
If I enter the screen it gives an incorrect format error on the conversion.
I have tried every type of casting and converting and parsing to decimal and double I could think of, but still keep getting the same error and it's just on Server 2012( not the core version)
Any help please and thanx
dim svalue as string = "182.82" 'Do conversions here if System.Convert.ToDecimal(svalue) < 0 then ' change grid colours end if
This is C# but it works.
double dvalue; string svalue = "182.82"; bool br = Double.TryParse(svalue, out dvalue);
Why not show the exact code you are using.
I think the regional settings are different on your server. You need to parse the number unsing specific culture:
Dim number As Double number = Double.Parse( aFld.Extract(11).StringValue, System.Globalization.NumberStyles.Number, System.Globalization.CultureInfo.InvariantCulture) If number < 0 Then ...
这篇关于字符串到dbl或dec不在Server2012上工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!