streamreader_object.Read Method

Returns the next byte from an input stream and removes it from the stream.

...steamreader_object.Read()

Prerequisites

The input stream must have been opened using a New to create the streamreader_object.

Parameters

None

Remarks

This method returns the next byte from the input stream as an integer. The byte is removed from the stream so that subsequent calls do not return it.

If any I/O error occurs or an end-of-file is encountered, this method returns -1.

For serial devices, this method blocks if no bytes are available to read.

Be careful when using this method to read data from a serial port since it blocks until a byte is available. If for some reason the byte is lost due to an error, this method will continue blocking and hang your procedure.

If no device or file is open, this method throws an Exception.

Examples

Dim com1 As New StreamReader("/dev/com1")
Dim c As Integer
c = com1.Read()

See Also

File and Serial I/O | streamreader_object.Peek | streamreader_object.ReadLine