gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 15:15:17 28 4
gpt4 key购买 nike

今天早上我在 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.

关于vb.net - IsNumeric 对于包含 D 字符的字符串返回 true,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8267024/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com