我是你的助手,把以下内容翻译为中文:
这是我第一次开发 VB 6.0 应用程序。 我正在尝试将大小为(164999)的巨大字节数组转换为 VB 6.0 中的长整型/整数数组,但它给了我一个溢出错误。
我的代码:
Dim tempByteData() As Byte // of size (164999)
Dim lCount As Long
Private Sub Open()
lCount = 164999 **//here I get the count i.e. 164999**
ReDim tempByteData(lCount - 1)
For x = 0 To obj.BinaryValueCount - 1
tempwaveformData(x) = CByte(obj.BinaryValues(x))
Next
tempByteData(lCount - 1) = BArrayToInt(tempByteData)
End Sub
Private Function BArrayToInt(ByRef bArray() As Byte) As Long
Dim iReturn() As Long
Dim i As Long
ReDim iReturn(UBound(bArray) - 1)
For i = 0 To UBound(bArray) - LBound(bArray)
iReturn(i) = iReturn(i) + bArray(i) * 2 ^ i
Next i
BArrayToInt = iReturn(i)
End Function
如何将所有字节数组数据转换为长整型/整型数组或任何其他存储这些字节数组的替代方法,以避免发生溢出异常。
ReDim tempByteData(164999)
将产生一个大小为165000的数组。您的示例似乎也正在丢弃结果为32位的数组。您还在使用逐渐递增的值i
来移动字节值,一旦达到约24就会溢出。 - Deanna01 00 00 00
还是00 00 00 01
)也许有一种方法可以直接在一次调用中进行复制,而无需对每个字节进行计算。 - Deanna