.dll para validar CGC/CPF
Alguém tem ou sabe onde consigo a dll para validação de CGC/CPF?
Obrigado.
:roll:
Obrigado.
:roll:
Leandro Marques
Curtidas 0
Respostas
Fernando
24/06/2003
por que vc não usa uma função em vez de dll eu acho que fica mais prático se vc precisar eu tenho
GOSTEI 0
Thaisandrade
24/06/2003
Leandro, concordo com o que foi dito. Se você usar uma função ao invés de uma dll vai ser melhor, além de consumir menos recursos. Fiz essa função a algum tempo ela é até grande e não tive tempo de melhorá-la.
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;
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
Carnette
24/06/2003
[quote:ecd491d0bd=´Leandro Marques´]Alguém tem ou sabe onde consigo a dll para validação de CGC/CPF?
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
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