Convert.ToInt32 (Double) converts double number to 32-bit signed integer.
Module Example
Public Sub Main()
Dim values() As Double = { Double.MinValue, -1.38e10, -2010.299, -12.98, _
0, 9.113e-16, 103.919, 2010.191, Double.MaxValue }
Dim result As Integer
For Each value As Double In values
Try
result = Convert.ToInt32(value)
Console.WriteLine(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