Convert.ToDecimal(String, IFormatProvider) converts string to decimal number using culture-specific format : Convert to Decimal « Development « VB.Net






Convert.ToDecimal(String, IFormatProvider) converts string to decimal number using culture-specific format

  

Imports System.Globalization

Module Example
   Public Sub Main()
      Dim values() As String = { "1.6789", "1 234,6789", _
                                 "1 456 789,0123" }
      Dim cultures() As CultureInfo = { New CultureInfo("en-US"),New CultureInfo("fr-FR") } 

      For Each culture As CultureInfo In cultures
         Console.WriteLine("String -> Decimal Conversion Using the {0} Culture",culture.Name)
         For Each value As String In values
            Console.Write("{0,20}  ->  ", value)
            Try
               Console.WriteLine(Convert.ToDecimal(value, culture))
            Catch e As FormatException
               Console.WriteLine("FormatException")
            End Try   
         Next
      Next                     
   End Sub
End Module

   
    
  








Related examples in the same category

1.Convert.ToDecimal (Boolean) converts Boolean value to decimal number.
2.Convert.ToDecimal (Double) converts double number to an equivalent decimal number.
3.Convert.ToDecimal (Int16) converts 16-bit signed integer to decimal number.
4.Convert.ToDecimal (Int32) converts 32-bit signed integer to decimal number.
5.Convert.ToDecimal (Int64) converts specified 64-bit signed integer to decimal number.
6.Convert.ToDecimal (Object) converts object to decimal number.
7.Convert.ToDecimal (SByte) converts 8-bit signed integer to decimal number.
8.Convert.ToDecimal (Single) converts single-precision floating-point number to decimal number.
9.Convert.ToDecimal (String) converts string to decimal number.
10.Convert.ToDecimal (UInt16) converts 16-bit unsigned integer to decimal number.
11.Convert.ToDecimal (UInt32) converts 32-bit unsigned integer to decimal number.
12.Convert.ToDecimal (UInt64) converts 64-bit unsigned integer to decimal number.