Mega Code Archive

 
Categories / VB.Net / Data Types
 

Converts a Decimal to an 8-bit unsigned integer

Option Strict On Module DecimalToS_ByteDemo     Public Sub DecimalToS_Byte(argument As Decimal)         Dim sByteValue As Object         Dim byteValue As Object         ' Convert the argument to an sbyte value.         Try             sByteValue = CByte(argument)         Catch ex As Exception             sByteValue = ex.GetType().Name         End Try         ' Convert the argument to a byte value.         Try             byteValue = CType(argument, Byte)         Catch ex As Exception             byteValue = ex.GetType().Name         End Try         Console.WriteLine( sbyteValue )         Console.WriteLine( byteValue )     End Sub     Public Sub Main( )         DecimalToS_Byte(78d)     End Sub End Module