用adodb.stream讀取文件并保存為數(shù)組的實(shí)現(xiàn)代碼
Function filenum(filename,i)
Dim st,s
Set st= CreateObject("ADODB.Stream")
st.Type = 2 '流類(lèi)型為文本
st.Mode = 3 '模式為讀寫(xiě)
st.Open
st.LineSeparator=13
st.LoadFromFile filename
Do While Not St.EOS
s = Split(st.readtext(), vbCrLf)
Loop
'MsgBox UBound(s) total
filenum=s(i)
st.Close
End function
MsgBox filenum("file.txt",2)