ExtensionMethod.NET Home of 880 C#, Visual Basic, F# and Javascript extension methods

Mascara CNPJ / CPF

Aplica mascara de CNPJ ou CPF brasileiro á uma string

Source

Imports System.ComponentModel

 <Extension()>
Public Function mascaraCNPJ_CPF(doc As String) As String
    Dim mascara As New MaskedTextProvider("00\.000\.000/0000-00")

    If doc.soNumero.Length = 11 Then
        mascara = New MaskedTextProvider("000\.000\.000-00")
    End If

    mascara.Set(doc)
    Return mascara.ToString()
End Function

Example

'input 11111111000199
'output 11.111.111/0001-99

documento.mascaraCNPJ_CPF()

Author: Alex Martins

Submitted on: 13 jan. 2017

Language: VB

Type: string

Views: 4979