Mega Code Archive

 
Categories / VB.Net / Data Types
 

Call parse with only AllowLeadingWhite and AllowTrailingWhite

Imports System.Numerics Imports System Imports System.Globalization Module Example    Public Sub Main()         Try            Console.WriteLIne(BigInteger.Parse("    ~9999   ", NumberStyles.AllowLeadingWhite Or NumberStyles.AllowTrailingWhite, New BigIntegerFormatProvider()))         Catch e As FormatException            Console.WriteLine("{0}: {1}   {2}", e.GetType().Name, vbCrLf, e.Message)         End Try                                       End Sub End Module Public Class BigIntegerFormatProvider : Implements IFormatProvider     Public Function GetFormat(ByVal formatType As Type) As Object Implements IFormatProvider.GetFormat         If formatType Is GetType(NumberFormatInfo) Then             Dim numberFormat As New NumberFormatInfo             numberFormat.NegativeSign = "~"             Return numberFormat         Else             Return Nothing         End If     End Function End Class