VBA:声明传递给DLL的struct中的内存空间或数组?

时间:2017-04-03 06:19:59

标签: vba excel-vba excel

我有一个结构,我通过引用从Excel传递到OS库。在VBA中,我需要在将引用传递给OS库之前声明并分配内存 当然,我可以只分配一些新内存,并使用指针操作VBA中的内存。但我更喜欢在VBA中使用VBA声明,以便我可以使用VBA语句来读取和设置值。 问题是struct包含一个大小为NCCS的字节数组。我无法使用VBA数组,因为它会分配SAFEARRAY结构。

除了命名和声明大量虚拟变量之外,还有什么方法吗?有没有办法使用数组?有没有办法声明一个指向虚拟变量区域的VBA数组?

Type termios
    c_iflag As Long 
    c_oflag As Long
    c_cflag As Long
    c_lflag As Long
    'c_cc(0 To NCCS - 1) As Byte
    c0 as byte: c1 as byte: c2 as byte: c3 as byte: c4 as byte
    c5 as byte: c6 as byte: c7 as byte: c8 as byte: c9 as byte
    c10 as byte: c11 as byte: c12 as byte: c13 as byte: c14 as byte
    c15 as byte: c16 as byte: c17 as byte: c18 as byte: c19 as byte
    c_ispeed As Long
    c_ospeed As Long
End Type

0 个答案:

没有答案