Mega Code Archive

 
Categories / VB.Net / Development
 

Convert ToDecimal (Int64) converts specified 64-bit signed integer to decimal number

Class Sample    Public Shared Sub Main()         Dim longVal As Long = 99999999999999              Dim decimalVal As Decimal              decimalVal = System.Convert.ToDecimal(longVal)         System.Console.WriteLine("{0} as a Decimal is {1}", _                                   longVal, decimalVal)              Try             longVal = System.Convert.ToInt64(decimalVal)             System.Console.WriteLine("{0} as a Long is {1}", _                                       decimalVal, longVal)         Catch exception As System.OverflowException             System.Console.WriteLine( _                 "Overflow in decimal-to-long conversion.")         End Try    End Sub End Class