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