Convert.ToInt16 (Char) converts Unicode character to the equivalent 16-bit signed integer.
Module Example
Public Sub Main()
Dim chars() As Char = { "a"c, "z"c, ChrW(7), ChrW(2010),ChrW(Short.MaxValue), ChrW(&hFFFE) }
Dim result As Short
For Each ch As Char in chars
Try
result = Convert.ToInt16(ch)
Console.WriteLine("'{0}' converts to {1}.", ch, result)
Catch e As OverflowException
Console.WriteLine("Unable to convert u+{0} to an Int16.",AscW(ch).ToString("X4"))
End Try
Next
End Sub
End Module
Related examples in the same category