我对数组有一些麻烦。
我有标准模块,其中包含一些子和私有变量。当通过它调用此模块时,userform_initialize
它会执行一些过程,然后它应该存储数组变量并等到单击按钮执行另一个过程。问题是当我调用其他过程时,这个数组变量不保存其元素。简化的例子是这样的:
Private exp2() as double 'declaration of module array variable
Private sub1()
//'some code which fills array exp2()
msgbox exp2(x) '- this message box shows correct information stored in variable exp2(x)
sub2
End sub
Private sub2()
Redim preserve exp2(0 to x)
msgbox exp2(x) - this message shows 0
End sub
请记住,这不完全是我的程序流程。重要的是存储数组变量 exp2() 供以后使用。