Convert.ToInt16 Method (Int64) converts 64-bit signed integer to 16-bit signed integer.
Module Example
Public Sub Main()
Dim numbers() As Long = { Int64.MinValue, -1, 0, 121, 340, Int64.MaxValue }
Dim result As Short
For Each number As Long In numbers
Try
result = Convert.ToInt16(number)
Console.WriteLine(result)
Catch e As OverflowException
Console.WriteLine("OverflowException")
End Try
Next
End Sub
End Module
Related examples in the same category