BinaryReader: ReadByte |
Reads the next byte in the stream, and advances the position one byte.
Public Function ReadByte ( ) As Byte
BinaryReader does not restore the file position after an unsuccessful read.
Exception | Condition |
---|---|
EndOfStreamException | The end of the stream is reached. |
ObjectDisposedException | The stream is closed. |
IOException | An I/O error occurs. |
The following example writes a 32-bit integer value then reads it back one byte at a time using ReadByte.
Public Sub Main() Dim Source As New MemoryStream Dim Reader As BinaryReader Dim Writer As BinaryWriter Set Writer = NewBinaryWriter(Source, New UnicodeEncoding) Writer.WriteValue &H80706050 Source.Position = 0 Set Reader = NewBinaryReader(Source) PrintByte Reader.ReadByte PrintByte Reader.ReadByte PrintByte Reader.ReadByte PrintByte Reader.ReadByte End Sub Private Sub PrintByte(ByVal Value As Byte) Debug.Print CorString.Format("&h{0:X2}", Value) End Sub ' This example code produces the following output. ' ' &h50 ' &h60 ' &h70 ' &h80