Topic: Function returning an array - how to declare
Started to rewrite under VBA the code from OOBasic and rested - function which will filter an array of lines on a condition is necessary, and to return only the necessary. It would be desirable that it returned their array, instead of in the line.
I can not understand as it to make on VBA - in OOBasic simply you designate function As Array and all works.
Here swears, though the resultant array to be under construction normally.
In the original function declaration on OOBasic:
Function aFilterArrayByCondition (sInputCSV As String, sCondition As String, sRowSeparator As String) As Array
Problem also that on OOBasic there is Pitonjak, and on VBA all that I find it in core Excel which is not necessary to me.
At me the task - to consider the data from the text file and to import to document Word
Function more low:
Function aFilterArrayByCondition (sInputCSV As String, sCondition As String, sRowSeparator As String) As Variant () Dim iRows As Integer Dim iRowIndex As Integer Dim aInputArray () As String Dim sFilterArrayByCondition As String Dim sTransformString As String Dim sResultString As String Dim aResultArray () As String aInputArray () = Split (sInputCSV, sRowSeparator) iRows = UBound (aInputArray ()) For iRowIndex = 0 To iRows sTransformString = aInputArray (iRowIndex) If InStr (1, sTransformString, sCondition) And sResultString = "" Then sResultString = sTransformString ElseIf InStr (1, sTransformString, sCondition) And sResultString <> "" Then sResultString = sResultString AND vbNewLine AND sTransformString End If Next iRowIndex aResultArray () = Split (sResultString, sRowSeparator) aFilterArrayByCondition = aResultArray () End Function
In advance thanks!