1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| Const STR_FILE_PATH = "c:\test.txt"
Const INT_PAIR = 0
Const INT_IMPAIR = 1
Const FOR_READING = 1
Dim objFso, objFile, arrFileContent, intLineCounter
Set objFso = CreateObject("Scripting.FileSystemObject")
intLineCounter = 0
Redim arrFileContent(intLineCounter)
On Error Resume Next
Set objFile = objFso.OpenTextFile(STR_FILE_PATH, FOR_READING)
Do Until objFile.AtEndOfStream
Redim Preserve arrFileContent(intLineCounter)
arrFileContent(intLineCounter) = objFile.ReadLine
intLineCounter = intLineCounter + 1
Loop
objFile.Close
On Error Goto 0
For intLineCounter = 0 To UBound(arrFileContent)
If (intLineCounter + 1) Mod 2 = INT_IMPAIR Then WScript.Echo "Ligne n° " & intLineCounter + 1 & vbCrLf & arrFileContent(intLineCounter)
Next |
Partager