VBcoders Browse New Submit Contact Sign In

No account? Register free

Forgot password?

Count Lines in a Text File

Files/File Controls/Input/Output   Visual Basic 3.0   Advanced   Wed 3rd February 2021

This code will count all of the lines in a text File. This code will work on any sized file, and is quicker than using LineInput or the FSO.

Inputs
A Valid FileName

Assumes
After being asked many times how you count the number of lines in a text file, i decided to write a function that would do it as quickly as possible. This function reads the file in in chunks. When it reads a chunk in, it counts the number of lines in that chunk, before reading the next chunk, and so on. You may find a different chunk size works better for you, feel free to experiment with it.

Returns
The number of lines contained in the passed filename.

Rate Count Lines in a Text File (6(6 Vote))
Count Lines in a Text File.bas

Count Lines in a Text File Comments

No comments yet — be the first to post one!

Post a Comment

0/1000 characters