Mega Code Archive

 
Categories / VB.Net Tutorial / Reflection
 

Use CType to convert decimal and Decimal to byte

Option Strict On Module Main     Public Sub DecimalToS_Byte(argument As Decimal)         Console.WriteLine(argument)         Dim sByteValue As Object         Try             sByteValue = CType(argument, Byte)         Catch ex As Exception             sByteValue = ex.GetType().Name         End Try         Console.WriteLine(sByteValue )     End Sub     Public Sub Main( )         DecimalToS_Byte(8d)         DecimalToS_Byte(New Decimal(7, 0, 0, false, 3))     End Sub End Module