Read Method

Reads a specified number of characters from a TextStream file and returns the resulting string.

object.Read(characters)

Arguments

object

Required. Always the name of a TextStream object.

characters

Required. Number of characters you want to read from the file.

Remarks

The following example illustrates how to use the Read method to read five characters from a file and return the resulting string:

Function ReadTextFileTest
   Const ForReading = 1, ForWriting = 2, ForAppending = 8
   Dim fso, f, Msg
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set f = fso.OpenTextFile("c:\testfile.txt", ForWriting, True)
   f.Write "Hello world!"
   Set f = fso.OpenTextFile("c:\testfile.txt", ForReading)
   ReadTextFileTest = f.Read(5)
End Function

See Also

Close Method | ReadAll Method | ReadLine Method | Skip Method | SkipLine Method | Write Method | WriteLine Method | WriteBlankLines Method

Applies To: TextStream Object

Сайт создан в системе uCoz