1
在VB6我有一个这样定义的动态数组,因为我不知道有多少价值添加运行程序VB6如何调整动态数组
Private myrray() As String
现在我有问题,这REDIMENSION而数组做。我曾尝试以下
Dim Upper As Integer
Upper = UBound(myArray) ' here I get the runtime error
If Err.Number Then
Upper = 0
Else
Upper = UBound(myArray) + 1
End If
的问题是上() - 函数总是给我运行时错误9“有效区域
我也尝试用其它方法外指标,在这里,我成为了同样的错误,但在else区块:
Dim Upper As Integer
If IsEmpty(myArray) Then
Upper = 0
Else
Upper = UBound(myArray) + 1 'here I get the same error in this line
End If
后来,我将使用上到redimensionze我像数组这增加了新的价值:
ReDim Preserve myArray(Upper)
myArray(Upper) = "new text"
有谁知道为什么,我怎么能解决这个问题,或者告诉我的其他的方式来redimensionize数组?
你可以用'myArray的=斯普利特(vbNullString) '得到一个初始化但是空的数组。 – Bob77