Byte Data Type (Visual Basic) 

Holds unsigned 8-bit (1-byte) integers ranging in value from 0 through 255.

Remarks

Use the Byte data type to contain binary data.

The default value of Byte is 0.

Programming Tips

  • Negative Numbers. Because Byte is an unsigned type, it cannot represent a negative number. If you use the unary minus (-) operator on an expression that evaluates to type Byte, Visual Basic converts the expression to Short first.

  • Format Conversions. When Visual Basic reads or writes files, or when it calls DLLs, methods, and properties, it can automatically convert between data formats. Binary data stored in Byte variables and arrays is preserved during such format conversions. You should not use a String variable for binary data, because its contents can be corrupted during conversion between ANSI and Unicode formats.

  • Widening. The Byte data type widens to Short, UShort, Integer, UInteger, Long, ULong, Decimal, Single, or Double. This means you can convert Byte to any of these types without encountering a System.OverflowException error.

  • Type Characters. Byte has no literal type character or identifier type character.

  • Framework Type. The corresponding type in the .NET Framework is the System.Byte structure.

See Also

Reference

Data Type Summary (Visual Basic)
Type Conversion Functions
Conversion Summary
System.Byte

Concepts

Efficient Use of Data Types