时间:2021-05-17 08:39:47 | 栏目:VBS | 点击:次
从 TextStream 文件中读入一整行字符(直到下一行,但不包括下一行字符),并返回结果字符串。
object.ReadLine
object 应为 TextStream 对象的名称。
下面例子说明如何使用 ReadLine 方法从 TextStream 文件中读取字符并返回字符串:
Function ReadLineTextFile Const ForReading = 1, ForWriting = 2 Dim fso, MyFile Set fso = CreateObject("Scripting.FileSystemObject") Set MyFile = fso.OpenTextFile("c:\testfile.txt", ForWriting, True) MyFile.WriteLine "Hello world!" MyFile.WriteLine "The quick brown fox" MyFile.Close Set MyFile = fso.OpenTextFile("c:\testfile.txt", ForReading) ReadLineTextFile = MyFile.ReadLine
' Returns "Hello world!"
End Function