Implements IFormatProvider : IFormatProvider « Data Structure « VB.Net






Implements IFormatProvider

 

Imports System.Globalization

Public Class DummyProvider
    Implements IFormatProvider

    Public Function GetFormat( argType As Type ) As Object Implements IFormatProvider.GetFormat

        Dim argStr  As String = argType.ToString( )
        If argStr = "" Then argStr = "Empty"
        argStr = argStr.Substring( argStr.LastIndexOf( "."c ) + 1 )

        Console.Write( "{0,-20}", argStr )
        Return Nothing

    End Function 
End Class

Module ConvertNonNumericProviderDemo

    Sub Main( )
        Dim provider    As New DummyProvider( )
        Dim Int32A      As String   = "-2"   
        Console.WriteLine( Convert.ToInt32( Int32A, provider ) )
    End Sub
End Module

   
  








Related examples in the same category