只读属性,返回 TextStream 文件中当前的行号。
object.Line
object 总是 TextStream 对象的名称。
在文件初始打开并写入任何字符之前,Line 等于 1。
下面的示例演示了Line 属性的用法:
[JScript] function GetLine() { var fso, f, r var ForReading = 1, ForWriting = 2; fso = new ActiveXObject("Scripting.FileSystemObject") f = fso.OpenTextFile("c:\\textfile.txt", ForWriting, true) f.WriteLine("Hello world!"); f.WriteLine("JScript is fun"); f.Close(); f = fso.OpenTextFile("c:\\textfile.txt", ForReading); r = f.ReadAll(); return(f.Line
); } [VBScript] Function GetLine Const ForReading = 1, ForWriting = 2 Dim fso, f, ra Set fso = CreateObject("Scripting.FileSystemObject") Set f = fso.OpenTextFile("c:\testfile.txt", ForWriting, True) f.Write "Hello world!" & vbCrLf & "VB Script is fun!" & vbCrLf Set f = fso.OpenTextFile("c:\testfile.txt", ForReading) ra = f.ReadAll GetLine =f.Line
End Function
应用于:TextStream 对象