Fórum .dll para validar CGC/CPF #166138
24/06/2003
0
Obrigado.
:roll:
Leandro Marques
Curtir tópico
+ 0Posts
24/06/2003
Fernando
Gostei + 0
24/06/2003
Thaisandrade
function CheckCPFCNJP(Texto: string; CNPJ: boolean): boolean;
var
X,Y,M,Soma, Digito: integer;
Aux,DigIni, DigFin: string;
begin
for X:=1 to Length(Texto) do
begin
if Texto[X] in [´0´..´9´] then
Aux:=Aux+Texto[X];
end;
case Length(Aux) of
11:begin
if CNPJ then
begin
Result:= False;
Exit;
end;
end;
14:begin
if not CNPJ then
begin
Result:= False;
Exit;
end;
end;
else
begin
Result:=False;
Exit;
end;
end;
if CNPJ then
begin
DigIni:= Copy(Aux,13,2);
Aux:= Copy(Aux,1,12);
end
else
begin
DigIni:= Copy(Aux,10,2);
Aux:=Copy(Aux,1,9);
end;
for Y:=1 to 2 do
begin
Soma:=0;
M:=2;
for X:= Length(Aux) downto 1 do
begin
Soma:= Soma+ StrToInt(Aux[X])*M;
Inc(M);
if (M > 9) and (CNPJ) then
M:=2;
end;
Digito:= 11 - (Soma mod 11);
if Digito >= 10 then
Digito:=0;
Aux:=Aux+ IntToStr(Digito);
DigFin:=DigFin + IntToStr(Digito);
end;
Result:=(DigFin = DigIni);
end;
Gostei + 0
24/06/2003
Carnette
Obrigado.
:roll:[/quote:ecd491d0bd]
Objetos DBEdit e Edit para validação de CNPJ/CPF funciona em qualquer versão do delphi...código fonte aberto..é só instalar e usar
http://www.carnette.kit.net/D5/checkdoc.zip
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)