不应用Let给数组赋值
应做为函数
Public Function XXX(T1() as double) as long
用时应为
dim a() as double
...
XXX(a())
其实有很多方法
如
Public Function XXX(T1 as variant) as long
variant是可以传入数组的
dim a as variant
a=array()
...
XXX(a)
也可用传入地址的方法
Public Function XXX(T1 as long,lb as long) as long
中间用函数CopyMemory把T1代表的地址按lb的长度复制到一个数组中
比如
redim tmpXXX(lb) as double
copymemory tmpxxx(0),byval t1,lb*8
'注意Double占8个字节
使用时
dim a() as double
XXX(varptr(a(0)),ubound(a)+1)
To daviddivad:
Get 是得到属性的值
我这样试过不行
Private dblA(3,4) as double
Public Property Let A(byRef dblTemp() as double)
dblA=dblTemp
End Property
编译DLL时,出现错误,"不能给数组赋值"
我就这样改写,
Public Property Let A(byRef dblTemp() as double)
dim i as integer,j as integer
for i=0 to 3
for j=0 to 4
dblA(i,j)=dblTemp(i,j)
next j
next i
End Property
编译通过,但我通过一个工程测试时,
dim clsCal as new clsDLL
dim bb(3,4) as double
clsCal.A=bb
测试工程编译时,出现不能给数组赋值。