Novo cálculo de CNPJ no Brasil - New CNPJ Calculation in Brazil

100 views
Skip to first unread message

valt...@valtecom.com.br

unread,
May 2, 2026, 6:53:26 PMMay 2
to Harbour Minigui
Boa noite caros amigos,
Essa informação interessa apenas aos desenvolvedores Brasileiros, pois trata-se de uma alteração drástica no formato do CNPJ(Cadastro Nacional de Pessoa Juridica) que ocorrerá a partir de 07/07/2026, a partir desta data os novos CNPJs poderão conter letras na sua composição, exceto so dois digitos verificadores, estes são aobrigatóriamente numeros, é a regra.
Segue em anexo um arquivo compactado com a função para calcular os digitos verificadores do novo formato de CNPJ, mas ela só vale para o novo método alfanumérico.
Valteçom
Uberaba MG Brasil

Good evening dear friends,
This information is only relevant to Brazilian developers, as it concerns a drastic change in the format of the CNPJ (National Registry of Legal Entities) that will occur from 07/07/2026. From this date, new CNPJs may contain letters in their composition, except for the two check digits, which are mandatory numbers, as a rule.
Attached is a compressed file with the function to calculate the check digits of the new CNPJ format, but it only works for the new alphanumeric method.

Valteçom
Uberaba MG Brazil
Novocnpj.zip

mario camboim filho

unread,
May 3, 2026, 11:57:29 AMMay 3
to Harbour Minigui
Obrigado Valteçom.

Marcelo Antonio Lázzaro Carli

unread,
May 4, 2026, 7:41:56 AMMay 4
to valt...@valtecom.com.br, Harbour Minigui

Obrigado

 

 

 

Att.

 

                Marcelo A. L. Carli

                      Marília/SP

         Capital Nacional do Alimento ®

      https://malc-informatica.ueniweb.com

                 Insta: @malcarli25

      Email / Skype: marcelo...@gmail.com

 

******************************************************************************

Se for repassar, apague o meu nome e endereço.

Ajude a combater a propagação de vírus e spams

coloque TODOS os destinatários em CÓPIA OCULTA (Cco / Bcc)

******************************************************************************

--
Visit our website on https://www.hmgextended.com/ or https://www.hmgextended.org/
---
You received this message because you are subscribed to the Google Groups "Harbour Minigui" group.
To unsubscribe from this group and stop receiving emails from it, send an email to minigui-foru...@googlegroups.com.
To view this discussion, visit https://groups.google.com/d/msgid/minigui-forum/1b79104d-e032-41c9-841f-1314fe194f71n%40googlegroups.com.


Não contém vírus.www.avast.com

Davisson Nunes De Magalhães

unread,
May 4, 2026, 8:10:11 AMMay 4
to Harbour Minigui
Gostaria de colaborar com esse código que válida CNPJ numérico e alfanumérico.
Passar os 14 dígitos sem ponto, barra ou traço.
Não passar o segundo parâmetro, É usado na recursão.

ValidaCNPJalfanumerico.png
CNPJalfanumerico.zip

Marcelo Antonio Lázzaro Carli

unread,
May 4, 2026, 9:18:44 AMMay 4
to Harbour Minigui

/*****************************************************************************

* SISTEMA  : ROTINA EVENTUAL                                                *

* PROGRAMA : CNPJNEW.PRG                                                              *

* OBJETIVO : Validar Novo Cnpj Alfa Numérico                                *

* AUTOR    : Marcelo Antonio Lázzaro Carli                                  *

* DATA     : 25.06.2024                                                     *

* ULT. ALT.: 25.06.2024                                                     *

*****************************************************************************/

#include <minigui.ch>

 

Function Main()

   REQUEST HB_LANG_PT

   REQUEST HB_CODEPAGE_PTISO

   REQUEST HB_CODEPAGE_PT850

   HB_LangSelect([PT])

   Set Navigation Extended

   Set(_SET_DEBUG, .F.)       &&& introduzida na build 24.05 (Standard)

 

   HB_SETCODEPAGE([PT850])

 

   Set wrap on

   Set talk off

   Set date briti             &&& data no formato dd/mm/aaaa

   Set dele on                &&& ignora registros marcados por deleção

   Set score off

   Set exact on

   Set ToolTip on

   Setcancel(.F.)             &&& evitar cancelar sistema c/ ALT + C

   Set cent on                &&& ano com 4 dígitos

   Set epoch to 2000          &&& ano a partir de 2000

   Set excl off               &&& abre arquivos em modo compartilhado

   Set navigation extended    &&& enter no lugar do tab

   Set language to portuguese &&& mensagens em português

   Set multiple off warning   &&& abrir 1 cópia somente

   Set browsesync on          &&& para o comando browse funcionar ok

   Set tooltipstyle balloon   &&& para mensagem dos campos em forma de balão

   Set menustyle extended     &&& padrão é standard, extended estilo office 2007

   Set programmaticchange off &&& introduzida na build 1.9.94

   Set(_SET_DEBUG, .F.)       &&& introduzida na build 24.05 (Standard)

 

   Define window Main at 0, 0 width 400 height 300 ICON "config.ico" NOTIFYICON "config.ico" Main title [Validar Novo Cnpj] NOSIZE NOMAXIMIZE

      @ 100, 140 BUTTON Bt_1 CAPTION [&Validar] WIDTH 120 TOOLTIP [Validar] BOLD ACTION {|| fCnpj_validar([06.117.473/0001-50])}

 

      on key escape action {|| ThisWindow.Release}

   End Window

 

   DoMethod([Main], [Center])

   DoMethod([Main], [Activate])

Return (Nil)

 

Function fCnpj_validar(pCNPJ, lMsg)

   Local lResult:= .T., nSoma:= nDigito:= nNum:= i:= j:= 0, cCnpj:= Iif(ValType(pCNPJ) == [U], [], Upper(pCNPJ)), cValidos:= [0123456789], cDv:= []

 

   hb_Default(@lMsg, .T.)

 

   cCnpj:= CharRem([/.-], cCnpj)

 

   If Empty(cCnpj)

      lResult:= .T.

   Else

      If Len(cCnpj) < 14

         lResult:= .F.

      Else

        For i:= 1 to 12

             If Substr(cCnpj, i, 1) $ [ABCDEFGHIJKLMNOPQRSTUWYXZ]

                cValidos:= [0123456789ABCDEFGHIJKLMNOPQRSTUWYXZ]

                Exit   

             Endif

         Next

 

         cDv := []

         nNum:= 5

 

         For j:= 1 to 2

             nSoma:= 0

             For i:= 1 to 12

                 nSoma+= (Asc(Substr(cCnpj, i, 1)) - 48) * nNum

                 nNum--

                 If nNum == 1

                    nNum:= 9

                 Endif

             Next

 

             If j == 2

                nSoma+= (2 * Val(cDv))

             Endif

 

             nDigito:= nSoma - (Int(nSoma / 11) * 11)

             If nDigito == 0 .or. nDigito == 1

                cDv:= cDv + [0]

             Else

                cDv:= cDv + Str(11 - nDigito, 1)

             Endif

             nNum:= 6

         Next

 

         If cDv # Substr(cCnpj, 13, 2)

            lResult:= .F.

         Endif

      Endif

 

      If !lResult

         If lMsg

            MsgInfo([CNPJ Incorreto ou Dígito Inválido...] + " [" + cDv + "]", [Cnpj: ] + pCNPJ)

         Endif

      Else

         If lMsg

            MsgInfo([CNPJ Correto...] + " [" + cDv + "]", [Cnpj: ] + pCNPJ)

         Endif

      Endif

   Endif

Return (lResult)

image001.png
Reply all
Reply to author
Forward
0 new messages