Convert Decimal to Integer
Imports System.Globalization
Module Example
Public Sub Main()
Dim values() As Decimal = { 199.55d, 9999.16d, Decimal.MaxValue }
Dim result As Integer
For Each value As Decimal In values
Try
result = Convert.ToInt32(value)
Console.WriteLine("Converted the {0} value '{1}' to the {2} value {3}.", _
value.GetType().Name, value, _
result.GetType().Name, result)
Catch e As OverflowException
Console.WriteLine("{0} is outside the range of the Int32 type.",value)
End Try
Next
End Sub
End Module
Related examples in the same category