KB-64106: Counting lines in text (TXT) files via E3.

Question:

How can I count the number of lines in a TXT file?

Solution:

To do so, you must use the methods in FileSystemObject object.

Example:

'Script for returning lines in a TXT file
i = 0

Set fso = CreateObject("scripting.FileSystemObject")
Set f = fso.OpenTextFile("C:\Test.txt",1)

Do Until f.AtEndOfStream
f.SkipLine
 i = i +1  
Loop 

Msgbox "Number of lines: " & i 
Print Friendly, PDF & Email

Este artigo foi útil? Was this helpful?

Classificação média - Average rating 0 / 5. Count: 0

Leave a Reply

Your email address will not be published.Required fields are marked *