Imports System
Imports System.Globalization
Imports Microsoft.VisualBasic
Module ToInt16ProviderDemo
Sub ConvertToInt16(ByVal numericStr As String, ByVal provider As IFormatProvider)
Dim defaultValue As Object = Nothing
Dim providerValue As Object = Nothing
Try
defaultValue = Convert.ToInt16(numericStr)
Catch ex As Exception
End Try
Try
providerValue = Convert.ToInt16(numericStr, provider)
Catch ex As Exception
End Try
Console.WriteLine(defaultValue)
Console.WriteLine(providerValue)
End Sub
Sub Main()
Dim provider As NumberFormatInfo = New NumberFormatInfo()
provider.NegativeSign = "neg "
provider.PositiveSign = "pos "
provider.NumberDecimalSeparator = "."
provider.NumberGroupSeparator = ","
provider.NumberGroupSizes = New Integer() {3}
provider.NumberNegativePattern = 0
ConvertToInt16("12345", provider)
End Sub
End Module