gpt4 book ai didi

vb6 - 在 Visual Basic 6 中绕过 64k 限制

转载 作者:行者123 更新时间:2023-12-03 13:32:46 24 4
gpt4 key购买 nike

我需要在 VB 中更新这个旧代码,但我遇到了问题。我已经在这个结构中添加了字段,现在当我尝试编译时,我得到了这个错误:

enter image description here

从网上阅读大多数人建议打破结构。问题是我从固件接收这种格式的数据。所以我想保持原样,但想办法解决这个问题。

我的结构如下所示:

Public Type DATA_V2_T
1_offsets(6399) As Single
2_offsets(6399) As Single
init_d_offsets(1199) As Single
init_a_offsets(1199) As Single
e_offsets(999) As Single
d_offsets(749) As Single
a_offsets(1199) As Single
final_e_offsets(6399) As Single
End Type

我现在添加的字段是 1_offsets 和 2_offsets 导致错误发生。这段代码似乎在某种程度上解决了这个问题,因为以下内容被定义为全局:
Global data_v2 AS DATA_V2_T

我也可以为结构做这样的事情吗?

编辑:我试图上课。我能够像这样定义我的变量:
    Private 1_offsets(6399) As Single
Private 2_offsets(6399) As Single
Private init_d_offsets(1199) As Single
Private init_a_offsets(1199) As Single
Private e_offsets(999) As Single
Private d_offsets(749) As Single
Private a_offsets(1199) As Single
Private final_e_offsets(6399) As Single

我创建了属性获取方法来访问这些私有(private)变量,如下所示:
Property Get p1_offsets() As Single()
p1_offsets = 1_offsets
End Property

编译器似乎并没有提示这一点。但是我还需要能够设置数组的值,并且我在属性设置方面遇到了麻烦。我怎样才能做到这一点?

最佳答案

最简单的方法是将数据定义为 Variant .这是一个例子:

Option Explicit

Private Sub Command1_Click()
Dim one_offsets(6399) As Single
one_offsets(0) = 33
one_offsets(1) = 44

Dim d As Data
Set d = New Data
d.one_offsets = one_offsets
End Sub

然后在您的数据类中:
Option Explicit

Private m_1_offsets As Variant
Private m_2_offsets As Variant
Private m_init_d_offsets As Variant
Private m_init_a_offsets As Variant
Private m_e_offsets As Variant
Private m_d_offsets As Variant
Private m_a_offsets As Variant
Private m_final_e_offsets As Variant

Public Property Get one_offsets() As Variant
one_offsets = m_1_offsets
End Property

Public Property Let one_offsets(ByVal Value As Variant)
m_1_offsets = Value
End Property

如果您随后检查 m_1_offsets在 Watch 窗口中,您将看到它被定义为 Variant/Single(0 to 6399) .

关于vb6 - 在 Visual Basic 6 中绕过 64k 限制,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61260402/

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