blairintern
New Member
- Joined
- Jul 16, 2007
- Messages
- 21
I have a function in which I return an array--however, when i go to set the completed array from within the function ("original" in my example) i receive the "Compile Error: Expected Array"
The array IssueMaturities is not declared anywhere else other than the function statement.
The array "original" is not declared anywhere else other than the function statement.
Here is the code that results in the error.
the ERROR occurs on the ReDim statement near the end of the function. I am attempting to resize the IssueMaturity array to reflect the size of the "original" array.
I'm really confused as to what I'm missing...
Thanks in advance!
The array IssueMaturities is not declared anywhere else other than the function statement.
The array "original" is not declared anywhere else other than the function statement.
Here is the code that results in the error.
Code:
Function IssueMaturities(original() As String) As String
Dim index As Integer
Dim tempValue As String
index = 0
Do
original(index) = Format(original(index), "YYYY")
tempValue = original(index) 'no messing with original
If tempValue < Format(Now, "yyyy") Then 'if year has passed, then...
tempValue = original(index + 1) ' set this value to the following
End If
original(index) = tempValue 'replace index value with next value
index = index + 1 'increment index
Loop Until index = 31
Do
tempValue = Format(original(index), "YYYY") ' no messing with original
If tempValue = original(index - 1) Then ' if current value is equal to next
ReDim Preserve original(0 To index - 1) 'then shrink array by 1
End If
Loop Until index >= UBound(original) ' continue until the (new) end has been reached
ReDim IssueMaturities(LBound(original) To UBound(original))
IssueMaturities() = original()
End Function
I'm really confused as to what I'm missing...
Thanks in advance!