Decimal.TryParse Method (String, NumberStyles, IFormatProvider, Decimal)
Imports System
Imports Microsoft.VisualBasic
Imports System.Globalization
Module MainClass
Sub Main( )
Dim value As String
Dim style As NumberStyles
Dim culture As CultureInfo
Dim number As Decimal
' Parse currency value using en-GB culture.
value = "1,999.63"
style = NumberStyles.Number Or NumberStyles.AllowCurrencySymbol
culture = CultureInfo.CreateSpecificCulture("en-GB")
If Decimal.TryParse(value, style, culture, number) Then
Console.WriteLine("Converted '{0}' to {1}.", value, number)
Else
Console.WriteLine("Unable to convert '{0}'.", value)
End If
End Sub
End Module
Related examples in the same category