Property:  TextStream.Line

Implemented in version 2.0
 
object.Line

The Line property is used to return the current line number in a text file. Upon opening a textfile and before any writing takes place, Line always returns '1'.

Code:
<%
dim filesys, text, readfile, contents, col, linumber
set filesys = CreateObject("Scripting.FileSystemObject")
Set text = filesys.CreateTextFile("c:\somefile2.txt")
text.Write "Find the last character in the text file"
text.close
set readfile = filesys.OpenTextFile("c:\somefile2.txt", 1, false)
do while readfile.AtEndOfStream <> true
    contents = readfile.Read(1)
    col = readfile.Column -1
    linumber = readfile.Line
loop
readfile.close
Response.Write "The last character in line " & linumber & " is '" & contents & "' and_
                                its column number is '" & col & "'."
%>

Output:
"The last character in line 1 is 'e' and its column number is '40'."


Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information