Mega Code Archive

 
Categories / VB.Net / Data Types
 

Convert Integer to Byte with CByte

Imports System Module Example     Sub Main()                   Dim int1 As Integer = 128         Try            Dim value1 As Byte = CByte(int1)            Console.WriteLine(value1)         Catch e As OverflowException            Console.WriteLine("{0} is out of range of a byte.", int1)         End Try    End Sub End Module