Convert.ToInt16 (Single) converts single-precision floating-point number to 16-bit signed integer.
Module Example
Public Sub Main()
Dim values() As Single = { 0, 9.1-16, 1.9, 2010.191, Single.MaxValue }
Dim result As Short
For Each value As Single In values
Try
result = Convert.ToInt16(value)
Console.WriteLine(result)
Catch e As OverflowException
Console.WriteLine("OverflowException")
End Try
Next
End Sub
End Module
Related examples in the same category