gpt4 book ai didi

excel - 当提供的值在其限制范围内时,字节数据类型出现溢出错误

转载 作者:行者123 更新时间:2023-12-04 21:45:11 24 4
gpt4 key购买 nike

这个问题在这里已经有了答案:





VBA overflow error with byte variables

(1 个回答)


去年关闭。




出于某种原因,即使字节数据类型值在其限制范围内,我也会收到溢出错误(运行时错误:6)。这是代码:

Sub Var_Dec2()
Dim myByt As Byte '0 to 255
myByt = 255
Range("a24").Value = myByt * 1000
End Sub
请帮我理解这个!!!谢谢你

最佳答案

您已经定义了 myByt作为字节,所以当你做 myByt * 1000你得到另一个字节数。它必须是 0 到 255 之间的值。
编辑:实际上,当您将 2 个不同的定义变量相乘时,输出将是最大的类型。

myLong = 1000
Range("a24").Value = myByt * 1000 'will raise error
Range("a24").Value = myByt * myLong 'will NOT raise error
更新 2:发现这个关于同一问题的老问题:
VBA overflow error with byte variables

关于excel - 当提供的值在其限制范围内时,字节数据类型出现溢出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67981909/

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