I am trying to read a file into an array list and then return it from a function. My function works to read the file to an array but when I try setting it to a variable it errors saying invalid procedure call or argument
My read file code
function readfile(strFile)
dim fs,objTextFile
set fs=CreateObject("Scripting.FileSystemObject")
dim arrStr
set objTextFile = fs.OpenTextFile(strFile)
Set userArrayList = CreateObject( "System.Collections.ArrayList" )
Do Until objTextFile.AtEndOfStream
strNextLine = objTextFile.Readline
userArrayList.add strNextLine
Loop
objTextFile.Close
set objTextFile = Nothing
set fs = Nothing
readfile = userArrayList
end function
Calling it in my code
arr = readfile("\\dc1\NETLOGON\Scripts\Add_Users\user.csv")
For Each present In arr
user = split(present,",")
WScript.Echo user(0) & user(1) & user(2) & user(3) & user(4) & "|"
Next
What am I doing wrong?