From: Check on

I am using multidimensional array in my function.

dim aReturnValue()
iIndexValue = 0
If iOccurrence > 0 Then
bStringFound = True
' Prepare the return value
ReDim Preserve aReturnValue(iIndexValue, 3)
aReturnValue(iIndexValue,0) = sMatchedValue
aReturnValue(iIndexValue,1) = iLineCount+1
aReturnValue(iIndexValue,2) = iOccurrence
aReturnValue(iIndexValue,3) = sListOfMatchFoundItems
iIndexValue = iIndexValue + 1
End If

Problem is I am getting subscript out of range in ReDim Preserve
aReturnValue(iIndexValue, 3)

I checked it on the net... I came to know that When using "Preserve"
with arrays. Only the upper bound of the last dimension in a
multidimensional array can be changed. If you change any of the other
dimensions, or the lower bound of the last dimension, you will get this
run-time error .

That means I cannot increase the number of rows... I can only increase
the no. of columns

Is there any way to do this?


--
Check
From: ekkehard.horner on
Check schrieb:
> I am using multidimensional array in my function.
>
> dim aReturnValue()
> iIndexValue = 0
> If iOccurrence > 0 Then
> bStringFound = True
> ' Prepare the return value
> ReDim Preserve aReturnValue(iIndexValue, 3)
> aReturnValue(iIndexValue,0) = sMatchedValue
> aReturnValue(iIndexValue,1) = iLineCount+1
> aReturnValue(iIndexValue,2) = iOccurrence
> aReturnValue(iIndexValue,3) = sListOfMatchFoundItems
> iIndexValue = iIndexValue + 1
> End If
>
> Problem is I am getting subscript out of range in ReDim Preserve
> aReturnValue(iIndexValue, 3)
>
> I checked it on the net... I came to know that When using "Preserve"
> with arrays. Only the upper bound of the last dimension in a
> multidimensional array can be changed. If you change any of the other
> dimensions, or the lower bound of the last dimension, you will get this
> run-time error .
>
> That means I cannot increase the number of rows... I can only increase
> the no. of columns
>
> Is there any way to do this?
>
>
Swap rows and columns:

ReDim Preserve aReturnValue(3, iIndexValue)
aReturnValue(0,iIndexValue) = sMatchedValue
...
 | 
Pages: 1
Prev: excel
Next: parse config files