下面的Visual Basic 6.0代码 - SP2给出溢出错误.有人可以解释一下原因吗?
Private Sub Form_Click()
Dim Qty as Long
Qty= 290 * 113 '' 112 is working fine
MsgBox Qty
End Sub
Run Code Online (Sandbox Code Playgroud)
113被输入为Byte.
290获取类型Integer因为它不适合一个字节.
因此表达式Integer被输入为290 * 113.一个Integer最多可以包含,Integer小于32767.
因此,在将结果存储到290 * 113变量之前,它会在乘法时溢出.
明确键入至少一个数字为Long:
Qty = 290& * 113
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1082 次 |
| 最近记录: |