Single.TryParse converts string in a style and culture-specific format to single-precision floating-point number
Module Example
Public Sub Main()
Dim value As String
Dim style As System.Globalization.NumberStyles
Dim culture As System.Globalization.CultureInfo
Dim number As Single
' Parse currency value using en-GB culture.
value = "1,234.56"
style = System.Globalization.NumberStyles.Number Or _
System.Globalization.NumberStyles.AllowCurrencySymbol
culture = System.Globalization.CultureInfo.CreateSpecificCulture("en-GB")
If Single.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