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