Name
TextStream.Read Method
Syntax
oTextStreamObj.Read(Characters)
oTextStreamObjUse: Required
Data Type: TextStream object
Any property or object variable returning a readable TextStream object.
CharactersUse: Required
Data Type: Long
The number of characters you want to read from the input stream.
Return Value
A String.
Availability
R
Description
Reads a given number of characters from a file or the standard input and returns the resulting string.
Rules at a Glance
Files opened for writing or appending can’t be read; you must first close the file and reopen it using the
ForReadingconstant.After the read operation, the file pointer advances
Characterscharacters, unless the end of the file is encountered.If the number of characters available to be read are less than
Characters, all characters will be read.When reading the standard input stream from the keyboard, program execution pauses until an end-of-line or end-of-stream character is encountered. However, only the first
Characterscharacters of the stream are read. If at leastCharacterscharacters are available in the input stream for subsequent read operations, program execution does not pause to wait for further keyboard input. The usual technique is to process keystrokes in a loop until the end-of-stream marker is encountered. For example:Do While Not oIn.AtEndOfStream sIn = oIn.Read(10) ' Read up to 10 characters ' process text Loop
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access