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.

/*****************************************************************************
* 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)
To view this discussion, visit https://groups.google.com/d/msgid/minigui-forum/91c1a1fb-90ca-4931-b9d3-f39fbd6ccb7fn%40googlegroups.com.