这是我的2美分,部分是从MP
- Option Explicit
- Sub test()
- Dim streams() As String
- '' please use a valid path in the following
- '' btw size of localldd.txt is 45.6 Mb
- '' you can get this file from:
- '' http://www.gomr.mms.gov/homepg/pubinfo/freeasci/pipeline/freepipe.html
- streams = FileToArray("D:\VBA_TEST\localldd.txt")
-
- Debug.Print (UBound(streams) - LBound(streams)) + 1; "line(s) of text retrieved."
- End Sub
- Function FileToArray(fName As String) As String()
- Dim txt As String
- Dim fs As Object
- Dim fl As Object
- Set fs = CreateObject("Scripting.FileSystemObject")
- Set fl = fs.OpenTextFile(fName)
- txt = fl.ReadAll
- fl.Close
- FileToArray = Split(txt, vbCr)
- End Function
~'J'~ |