Convert.ToDouble (String, IFormatProvider) converts string to double using culture-specific format
Imports System
Imports System.Globalization
Imports Microsoft.VisualBasic
Module ToDoubleProviderDemo
Sub ConvertToDouble( numericStr As String,provider As IFormatProvider )
Dim defaultValue As Object
Dim providerValue As Object
Try
defaultValue = Convert.ToDouble( numericStr )
Catch ex As Exception
Console.WriteLine( ex )
End Try
Try
providerValue = Convert.ToDouble( numericStr, provider )
Catch ex As Exception
Console.WriteLine( ex )
End Try
Console.WriteLine( defaultValue )
Console.WriteLine( providerValue )
End Sub
Sub Main( )
Dim provider As NumberFormatInfo = new NumberFormatInfo( )
provider.NumberDecimalSeparator = ","
provider.NumberGroupSeparator = "."
provider.NumberGroupSizes = New Integer( ) { 3 }
ConvertToDouble( "123456789", provider )
End Sub
End Module
Related examples in the same category