Convert.ToInt64(String, IFormatProvider) converts string to 64-bit signed integer using culture-specific format : Convert to Int64 « Development « VB.Net






Convert.ToInt64(String, IFormatProvider) converts string to 64-bit signed integer using culture-specific format

  

Imports System.Globalization

Public Module Example
   Public Sub Main()
      Dim customProvider As New NumberFormatInfo()
      customProvider.NegativeSign = "neg "
      customProvider.PositiveSign = "pos "

      Dim providers() As NumberFormatInfo = {customProvider,NumberFormatInfo.InvariantInfo }

      Dim numericStrings() As String = { "123456789", "+123456","pos 12345", "-123", _
                                         "neg 123456789", "9.","13,456,789", "(123)", "-9" }

      For ctr As Integer = 0 to 1
         Dim provider As IFormatProvider = providers(ctr)
         Console.WriteLine(IIf(ctr = 0, "Custom Provider:", "Invariant Culture:"))
         For Each numericString As String In numericStrings
            Console.Write(numericString)
            Try
               Console.WriteLine("{0,22}", Convert.ToInt32(numericString, provider))
            Catch e As Exception
               Console.WriteLine("Exception")
            End Try
         Next
         Console.WriteLine()
      Next
   End Sub 
End Module 

   
    
  








Related examples in the same category

1.Convert.ToInt64 (Boolean) converts Boolean value to 64-bit signed integer.
2.Convert.ToInt64 (Byte) converts 8-bit unsigned integer to 64-bit signed integer.
3.Convert.ToInt64 (Char) converts Unicode character to 64-bit signed integer.
4.Convert.ToInt64 (Decimal) converts decimal number to 64-bit signed integer.
5.Convert.ToInt64 (Double) converts double-precision floating-point number to 64-bit signed integer.
6.Convert.ToInt64 (Int16) converts 16-bit signed integer to 64-bit signed integer.
7.Convert.ToInt64 (Object) converts object to a 64-bit signed integer.
8.Convert.ToInt64 (SByte) converts 8-bit signed integer to 64-bit signed integer.
9.Convert.ToInt64 (Single) converts single-precision floating-point number to 64-bit signed integer.
10.Convert.ToInt64 (String) converts string to 64-bit signed integer.
11.Convert.ToInt64 (String, Int32) converts string in a base to a 64-bit signed integer.
12.Convert.ToInt64 (UInt16) converts 16-bit unsigned integer to the equivalent 64-bit signed integer.
13.Convert.ToInt64 (UInt32) converts 32-bit unsigned integer to 64-bit signed integer.
14.Convert.ToInt64 (UInt64) converts 64-bit unsigned integer to 64-bit signed integer.