?eval("len(some number)") returns 最大值为 29
?eval("len(some number)") returns maximum of 29
已使用 Microsoft Visual Basic for applications 7.0.1628 进行测试
当我尝试(直接)执行时:
?eval("len(12345678901234567890123456789)")
它 returns 29 这是正确的。
?eval("len(123456789012345678901234567890)")
应该 return 30 但 returns 20.
?eval("len('123456789012345678901234567890')")
returns 30 正确。
所以问题是:
如果
?len(12341)
return一个错误,因为它需要一个字符串,为什么 eval 使它工作但只到第 29 个数字?
您的问题不在于 Eval,而在于 Len。
对于字符串或变体以外的任何东西,Len() 的作用类似于 C 中的 sizeof() 运算符,即它 returns 用于存储变量的字节数:
例如:
Public Function test()
Dim intTest As Integer
Dim lngTest As Long
intTest = 12345
Debug.Print "Len (Int): " & Len(intTest)
lngTest = 12345
Debug.Print "Len (Long): " & Len(lngTest)
End Function
输出:
长度(整数):2
Len(长):4
已使用 Microsoft Visual Basic for applications 7.0.1628 进行测试
当我尝试(直接)执行时:
?eval("len(12345678901234567890123456789)")
它 returns 29 这是正确的。
?eval("len(123456789012345678901234567890)")
应该 return 30 但 returns 20.
?eval("len('123456789012345678901234567890')")
returns 30 正确。
所以问题是: 如果
?len(12341)
return一个错误,因为它需要一个字符串,为什么 eval 使它工作但只到第 29 个数字?
您的问题不在于 Eval,而在于 Len。
对于字符串或变体以外的任何东西,Len() 的作用类似于 C 中的 sizeof() 运算符,即它 returns 用于存储变量的字节数:
例如:
Public Function test()
Dim intTest As Integer
Dim lngTest As Long
intTest = 12345
Debug.Print "Len (Int): " & Len(intTest)
lngTest = 12345
Debug.Print "Len (Long): " & Len(lngTest)
End Function
输出:
长度(整数):2
Len(长):4