Microsoft® Visual Basic® Scripting Edition Read Method | Language Reference Version 2

See Also Applies to

##### Description

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

##### Syntax

> object.Read(characters)

> The Read method syntax has these parts:

> Part | Description
> 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

© 1998 Microsoft Corporation. All rights reserved. Terms of Use.