Imports System.Numerics
Imports System
Module Example
Public Sub Main()
Dim goodDecimal As BigInteger = 9999
Dim badDecimal As BigInteger = CType(Decimal.MaxValue, BigInteger)
badDecimal += BigInteger.One
Dim decimalFromBigInteger As Decimal
decimalFromBigInteger = CType(goodDecimal, Decimal)
Console.WriteLine(decimalFromBigInteger)
decimalFromBigInteger = CDec(goodDecimal)
Console.WriteLine(decimalFromBigInteger)
Try
decimalFromBigInteger = CType(badDecimal, Decimal)
Console.WriteLine(decimalFromBigInteger)
Catch e As OverflowException
Console.WriteLine("Unable to convert {0}:{1} {2}",badDecimal, vbCrLf, e.Message)
End Try
End Sub
End Module