Method: Read for TextStream
- Updated2024-09-12
- 1 minute(s) read
FileSystemObject and Dictionary > Methods > Method: Read for TextStream
Method: Read for TextStream
Reads one or more characters from a TextStream file.
sRead = Object.Read(Characters)
| Object | TextStream Object with this method |
| Characters | LongInteger Specifies the number of characters to read. |
| sRead | String Receives the read text. |
The following example opens a text file into which it writes a text line. Then the example opens the file for reading and reads the first four characters:
Function ReadCharacters(sFile) Const ForReading = 1, ForWriting = 2 Dim fso, oMyFile Set fso = CreateObject("Scripting.FileSystemObject") Set oMyFile= fso.OpenTextFile(sFile, ForWriting, True) oMyFile.Write "This is a text" Set oMyFile = fso.OpenTextFile(sFile, ForReading) ReadCharacters = oMyFile.Read(4) End Function
See Also
Related Topics
Command: ExecuteExclusiveBegin | Command: ExecuteExclusiveEnd | Command: ExecuteExclusiveEndAll