Dayus
asked on
Files Reading Question!
Is there a Function that return the number of line in a file or i have to make it make it myself?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You could use FileLen function to get the size of the file in bytes. but if you want number of lines, then write your own function similar to ....
Private Function NumOfLines(FileName as String) as Long
Dim strLine as String
NumOfLines = 0
If (Dir(FileName) = "") then Exit Sub
Open FileName For Input as #1
Do
Line Input #1, strLine
NumOfLines = NumOfLines + 1
Loop While (Not EOF(1))
Close #1
End Function
Good Luck!
Private Function NumOfLines(FileName as String) as Long
Dim strLine as String
NumOfLines = 0
If (Dir(FileName) = "") then Exit Sub
Open FileName For Input as #1
Do
Line Input #1, strLine
NumOfLines = NumOfLines + 1
Loop While (Not EOF(1))
Close #1
End Function
Good Luck!
ASKER
both great answer the first get the point...
oooooo... that was pretty close! credit to supunr, though, neat answer.
Open inputfile For Input As #2
While Not EOF(2)
Line Input #2, linebuffer
linecount = linecount + 1
Wend
Close #2
Linecount contains number of lines.
While Not EOF(2)
Line Input #2, linebuffer
linecount = linecount + 1
Wend
Close #2
Linecount contains number of lines.
ASKER