Public Function File2ALists(ByVal vFile As Variant, Optional ByVal strDelim As String) As clsArrayLists
'Implements Line2AList() to create an ArrayLists object 'collection/representation of an entired file 'Note: Be careful to lose memory when file is large Dim objArrayLists As clsArrayLists Dim intFile As Integer On Error Goto errFile2ALists Set objArrayLists = New clsArrayLists intFile = GetFileNum(vFile, "Input", "Read") Do While Not EOF(intFile) 'Loop to the end-of-file and add each line to the collection objArrayLists.Add Line2AList(ReadFileLine(intFile), strDelim) Loop 'Close vFile if this function opened it If VarType(vFile) = vbString Then Close #intFile Set File2ALists = objArrayLists Set objArrayLists = Nothing Exit Function errFile2ALists: ShowErrorMess Err, "File2ALists" End Function Inputs:vFile As Variant The filename or file number of the file To read strDelim As String The delimiter In the delimited text Returns: Returns a clsArrayLists collection object containing the entire delimited text file. Assumes: This function requires the ArrayList DLL, GetFileNum(), ReadFileLine(), Line2AList() and ShowErrorMess(), all of which are available for download as entries of this author. |