# ReadLine 方法
object.ReadLine
从 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
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
应用于