10
votes

I have some VBScript code where a function returns an array.

function PreProcessFile (sFile)

    dim deData(3)

    ''populate deData with strings

    PreProcessFile = deData

End function

The code calling this function errs with a type mismatch. Any thoughts?

'' VBScript source code
Dim m_deData(3)
set m_deData = PreProcessFile("someFile.txt")
1

1 Answers

16
votes

Don't explicitly dim the size of the array outside the function and don't use set:

'' VBScript source code
Dim m_deData
m_deData = PreProcessFile("someFile.txt")