Parse string using "$" as the currency symbol for en-GB and en-us cultures
Imports System
Imports Microsoft.VisualBasic
Imports System.Globalization
Module MainClass
Sub Main( )
Dim value As String
Dim number As Decimal
Dim style As NumberStyles
Dim provider As CultureInfo
value = "$6,543.51"
style = NumberStyles.Number Or NumberStyles.AllowCurrencySymbol
provider = New CultureInfo("en-GB")
Try
number = Decimal.Parse(value, style, provider)
Console.WriteLine("'{0}' converted to {1}.", value, number)
Catch e As FormatException
Console.WriteLine("Unable to parse '{0}'.", value)
End Try
End Sub
End Module
Related examples in the same category