Option Explicit
' Create a user-defined data type containing 3 elements
Private Type CUST
strCSV As String
strCUSTNAME As String
strCUSTEMAIL As String
End Type
' Dim an array of the CUST datatype
Private arrCUST() As CUST
Private Sub Form_Load()
Dim nFile As Integer
Dim str As String
Dim temparr() As String
Dim i As Integer
Dim strsearchname As String
Dim F As String
' Get a file number to be used for file I/O
nFile = FreeFile
' Open a file that is assumed to be in the same folder as the exe
Open App.Path & "\accountcodes.txt" For Input As #nFile
' Loop through all the lines in the file until end of file.
Do Until EOF(nFile)
' Read a line into the str variable
Line Input #nFile, str
' Split the line into pieces separated by spaces
temparr = Split(str, ",")
' Increase the size of arrCUST as needed. It starts off at zero
' (which will hold 1 record) because i is initially = 0
ReDim Preserve arrCUST(i)
' Move the pieces of the line into arrCUST. UBound(arrCUST) calculates
' to the highest available record
arrCUST(UBound(arrCUST)).strCSV = temparr(0)
arrCUST(UBound(arrCUST)).strCUSTNAME = temparr(1)
arrCUST(UBound(arrCUST)).strCUSTEMAIL = temparr(2)
' Add 1 so that the ReDim can increase the array.
i = i + 1
Loop
' Close the file you opened
Close #nFile
strsearchname = "c:\output\*.csv"
F = Dir(strsearchname, vbReadOnly)
While F <> ""
MsgBox "Processing file: " & F
'further code
F = Dir()
Wend
End Sub