A custom NumberFormatInfo object that defines the tilde (~) as the negative sign : NumberFormatInfo « I18N Internationlization « VB.Net Tutorial






Imports System.Globalization

Module Example
   Public Sub Main()
      Dim nf As New NumberFormatInfo()
      nf.NegativeSign = "~" 

      Dim values() As String = { "-103", "~16" }
      Dim providers() As IFormatProvider = { nf, CultureInfo.InvariantCulture }

      For Each provider As IFormatProvider In providers
         Console.WriteLine("Conversions using {0}:", CObj(provider).GetType().Name)
         For Each value As String In values
            Try
               Console.WriteLine("Converted '{0}' to {1}.",value, SByte.Parse(value, provider))
            Catch e As FormatException
               Console.WriteLine("Unable to parse '{0}'.", value)   
            Catch e As OverflowException
               Console.WriteLine("'{0}' is out of range of the SByte type.", value)         
            End Try
         Next
      Next      
   End Sub
End Module








18.4.NumberFormatInfo
18.4.1.A custom NumberFormatInfo object that defines the tilde (~) as the negative sign
18.4.2.NumberFormatInfo recognizes the "pos" as the positive sign and "neg" as the negative sign.