Decimal.TryParse Method (String, NumberStyles, IFormatProvider, Decimal) : Decimal Parse « Data Types « VB.Net






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

1.Decimal.Parse Method Converts string to Decimal using the specified style and culture-specific format.
2.Parse string using "." as the thousands separator and " " as the decimal separator.
3.Decimal.TryParse Method Converts string to Decimal