因此,我试图通过拆分2个宏来保持代码整洁。
第一个构造了2x二维数组,用于第二个宏。我已经用Public声明将这2个数组声明为全局数组。
但是它们仍然没有传递给Call语句之后的第二个宏。我使用Watches监视这些数组,在Call语句之后立即清除了它们。
我想念什么吗?
谢谢
答案 0 :(得分:1)
不要将数组设为公共或全局。将数组从第一个传递到第二个。
sub first()
dim i as long, j as long, arr as variant
redim arr(0 to 1, 0 to 1)
for i=lbound(arr, 1) to ubound(arr, 1)
for j=lbound(arr, 2) to ubound(arr, 2)
arr(i, j) = i*j
next j
next i
second arr
end sub
sub second(vals as variant)
dim i as long, j as long
for i=lbound(vals, 1) to ubound(vals, 1)
for j=lbound(vals, 2) to ubound(vals, 2)
debug.print vals(i, j)
next j
next i
end sub