Office中国论坛/Access中国论坛

标题: [求助]声明数组 [打印本页]

作者: 28795277    时间: 2005-8-25 21:26
标题: [求助]声明数组
VBA中好像不能声明这样的数组变量!

dim v as integer

dim arr() as integer

...

Redim arr(0 to v) as integer

...

也就是说VBA在数组中不支持用变量来代替数组的下限,如果是这样的话该怎么办?
作者: Trynew    时间: 2005-8-25 22:58
可以的,但变量V必须在Redim语句前赋值,否则相当于:ReDim arr(0 To 0) As Integer

Public Sub xxx()

Dim v As IntegerDim arr() As Integerv = 5

ReDim arr(0 To v) As Integer

arr(1) = 3

arr(3) = 5

Debug.Print arr(1) & arr(2) & arr(3)

End Sub


作者: 28795277    时间: 2005-8-26 01:36
可能是我哪里出了问题,我再看看!再次感谢TryNew!




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3