有效的数字格式? [英] valid number formats ?
问题描述
如何查看字符串是否与有效的数字格式相对应?
例如:
1,000.00
1.000,00
1 000,00
1''000.00
如何检查以上内容是否有效数字格式?
问候
Dim x as Double
如果Double.TryParse(" 1,000.00",Any,CultureInfo.InvariantCulture,x)那么
''它被解析而x包含结果
Else
''它失败了
结束如果
-
Jonathan Allen
" Sam" < SA ************** @ voila.fr>在消息中写道
news:11 ********************* @ g44g2000cwa.googlegro ups.com ...
如何查看字符串是否符合有效的数字格式?
例如:
1,000.00
1.000,00
1 000,00
1''000.00
如何检查以上是有效的数字格式?
问候
"萨姆和QUOT; < SA ************** @ voila.fr> schrieb:如何检查字符串是否符合有效的数字格式?
例如:
1,000.00
1.000,00
1 000,00
1''000.00
如何检查以上是有效的数字格式?
您提供的样本是concreate实例一定数量
格式。您可以使用''Double.TryParse''检查字符串是否可以解析
并解释为数字。
-
MS Herfried K. Wagner
MVP< URL:http://dotnet.mvps.org/>
VB< URL:http:/ /classicvb.org/petition/>
您好,
您的回复。我已经尝试了Jonathan的代码:
Dim x As Double
如果是Double.TryParse(行(格式化)。ToString,
NumberStyles.Any,CultureInfo.InvariantCulture,x)然后
.....
我不明白为什么用1.000,00它返回false
和1,000.00它返回true。 1,000.00是有效格式吗?我会
认为这是.....
Hi,
How can I check if a string corresponds to a valid number format ?
e.g :
1,000.00
1.000,00
1 000,00
1''000.00
How to check the above are valid number formats ?
Regards
Dim x as Double
If Double.TryParse("1,000.00", Any, CultureInfo.InvariantCulture, x) Then
''it was parsed and x contains the result
Else
''it failed
End If
--
Jonathan Allen
"Sam" <sa**************@voila.fr> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...Hi,
How can I check if a string corresponds to a valid number format ?
e.g :
1,000.00
1.000,00
1 000,00
1''000.00
How to check the above are valid number formats ?
Regards
"Sam" <sa**************@voila.fr> schrieb:How can I check if a string corresponds to a valid number format ?
e.g :
1,000.00
1.000,00
1 000,00
1''000.00
How to check the above are valid number formats ?
The samples you are giving are concreate instances of certain number
formats. You can use ''Double.TryParse'' to check if the string can be parsed
and interpreted as a number.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Hi,
Thx for your replies. I''ve tried Jonathan''s code:
Dim x As Double
If Double.TryParse(row("Formatting").ToString,
NumberStyles.Any, CultureInfo.InvariantCulture, x) Then
.....
I don''t understand why with 1.000,00 it returns false
and with 1,000.00 it returns true. Is 1,000.00 a valid format? I would
have thought it was.....
这篇关于有效的数字格式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!