Convert.ToUInt16 (String, IFormatProvider) converts string to 16-bit unsigned integer in culture settings
Imports System.Globalization
Module Example
Public Sub Main()
Dim provider As New NumberFormatInfo()
provider.PositiveSign = "pos "
provider.NegativeSign = "neg "
Dim values() As String = { "2010", "+2010", "pos 2010","65535" }
For Each value As String In values
Console.Write("{0,-12:} --> ", value)
Try
Console.WriteLine("{0,17}", Convert.ToUInt16(value, provider))
Catch e As FormatException
Console.WriteLine("{0,17}", e.GetType().Name)
End Try
Next
End Sub
End Module
Related examples in the same category