运行时错误“6":Visual Basic
问题描述:
我使用的是 Visual Basic 6
我有以下代码结构:
FUNCNINFO 是一个结构体
I am using Visual Basic 6
I have the following code structure:
FUNCNINFO is a structure
Public funcTable() As FUNCNINFO
-----
------
ReDim Preserve funcTable(0 To upsize + ns)
当 (upsize + ns) 的值超过 32766 时,会给出运行时溢出错误 '6'您知道原因和解决方案吗?
When the value of (upsize + ns) is exceeding 32766,it is giving the runtime overflow error '6' Do you have any idea of the cause and the solution?
答
VB6 的 Integer
类型是 16 位,所以不能存储大于 32767 的值,它的 Long
是 32位整数类型,因此以下将起作用;
VB6's Integer
type is 16 bits so cannot store a value > 32767, its Long
that's the 32 bit integer type so the following will work;
Dim upsize As Long
Dim ns As Long
upsize = 32766
ns = 12345
ReDim Preserve funcTable(0& To upsize + ns)