Pages

Sunday, 3 April 2011

Number Decimal Separator

Remember, Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator gives us the character used for decimals, then we can :

Dim separator As String = Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator

Dim strNumber As String = "1.0" 'A string number with dot as separator
strNumber = strNumber.Replace(".", separator).Replace(",",separator) 'Replaces dot or comma for the current separator

Dim value As Double = CDbl(strNumber)' Casts the string to Double

No comments:

Post a Comment