Network Engineer -- A Looking Glass
A look into my work as a Network Engineer
Tuesday, March 07, 2006
Read Any File Line by Line
Option Explicit
Dim objFSO
Dim filePath,arrLines(),y,strComputer
Set objFSO = CreateObject("Scripting.FileSystemObject")
filePath = "ip_list.txt"
readEntireFile(filePath)
For y=0 To UBound(arrLines)
strComputer = arrLines(y)
MsgBox strComputer,0,"Array Element: " & y
Next
'*******************************************************
Function readEntireFile(path)
Const ForReading = 1
Dim myFile, x
Set myFile = objFSO.OpenTextFile(path, ForReading, False)
x=0
Do While myFile.AtEndOfStream <> True
ReDim Preserve arrLines(x)
arrLines(x) = myFile.ReadLine
x=x+1
Loop
myFile.Close
readEntireFile = arrLines
End Function
'*********************************************|
Newer Posts
Older Posts
Home
Subscribe to:
Posts (Atom)