vb.net – 对于包含D字符的字符串,IsNumeric返回true

前端之家收集整理的这篇文章主要介绍了vb.net – 对于包含D字符的字符串,IsNumeric返回true前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我今天早上在VB6应用程序中遇到了一个奇怪的错误,这都是因为IsNumeric没有像我预期的那样工作.有人可以解释为什么?对我来说,这似乎是一个错误.

代码在消息框中显示4.15877E 62:

Dim strMessage As String
strMessage = "0415877D57"
If IsNumeric(strMessage) Then
    MsgBox CDbl(strMessage)
Else
    MsgBox "not numeric"
End If

我猜测运行时引擎错误地认为D实际上是E?
我认为这是一个错误,因为VB.NET中完全相同的代码输出不是数字
这是IsNumeric的已知问题吗?

如果您查看VB6文档:

Note Floating-point values can be expressed as mmmEeee or mmmDeee,in which mmm is the mantissa and eee is the exponent (a power of 10). The highest positive value of a Single data type is 3.402823E+38,or 3.4 times 10 to the 38th power; the highest positive value of a Double data type is 1.79769313486232D+308,or about 1.8 times 10 to the 308th power. Using D to separate the mantissa and exponent in a numeric literal causes the value to be treated as a Double data type. Likewise,using E in the same fashion treats the value as a Single data type.

原文链接:https://www.f2er.com/vb/255580.html

猜你在找的VB相关文章