Fórum pis digito verificador #213577
12/02/2004
0
pis digito verificador
eu tenho uma funcao que verifica o pis mas ela nao funciona direito pois em augums casos ela diz que o pis ta ok mas quando eu coloco aquele pis mum programa oficial como irpj por exemplo e diz que ta errado. auguem tem uma funcao que funcione?
minha rotina e essa
procedure TForm1.Button1Click(Sender: TObject);
var
vpis:Boolean;
i, wsoma, wm11, wdv, wdigito: integer;
Dado: String;
begin
dado:=Edit1.Text;
if Trim(Dado) <> ´´ then
begin
wdv := StrToInt(copy(Dado, 11, 1));
wsoma := 0;
wm11 := 2;
for i := 1 to 10 do
begin
wsoma := wsoma + (wm11 * StrToInt(Copy(Dado, 11 -i, 1)));
if wm11 < 9 then
wm11 := wm11 + 1
else
wm11 := 2;
end;
wdigito := 11 - (wsoma mod 11);
if wdigito > 9 then
wdigito := 0;
if wdv = wdigito then
begin
//Application.MessageBox(´O valor informado é válido!´, ´Aviso!´, mb_IconStop+mb_ok);
vpis := True;
end
else
begin
Application.MessageBox(´O valor informado não é válido!´, ´Atenção!´, mb_IconStop+mb_ok);
vpis := false;
end; end; end;
se auguem tiver outra que funcione melhor eu agradeço
eu tenho uma funcao que verifica o pis mas ela nao funciona direito pois em augums casos ela diz que o pis ta ok mas quando eu coloco aquele pis mum programa oficial como irpj por exemplo e diz que ta errado. auguem tem uma funcao que funcione?
minha rotina e essa
procedure TForm1.Button1Click(Sender: TObject);
var
vpis:Boolean;
i, wsoma, wm11, wdv, wdigito: integer;
Dado: String;
begin
dado:=Edit1.Text;
if Trim(Dado) <> ´´ then
begin
wdv := StrToInt(copy(Dado, 11, 1));
wsoma := 0;
wm11 := 2;
for i := 1 to 10 do
begin
wsoma := wsoma + (wm11 * StrToInt(Copy(Dado, 11 -i, 1)));
if wm11 < 9 then
wm11 := wm11 + 1
else
wm11 := 2;
end;
wdigito := 11 - (wsoma mod 11);
if wdigito > 9 then
wdigito := 0;
if wdv = wdigito then
begin
//Application.MessageBox(´O valor informado é válido!´, ´Aviso!´, mb_IconStop+mb_ok);
vpis := True;
end
else
begin
Application.MessageBox(´O valor informado não é válido!´, ´Atenção!´, mb_IconStop+mb_ok);
vpis := false;
end; end; end;
se auguem tiver outra que funcione melhor eu agradeço
Flaviocont
Curtir tópico
+ 0
Responder
Posts
12/02/2004
Motta
function ValidaPis(Dado: String): boolean;
function FillPis (s: string): string;
begin
while length(s) < 11 do
s:= ´0´+s;
result:= s;
end;
var
i,wsoma,wm11,wdv,wdigito: integer;
begin
ValidaPIS := False;
Dado := FillPis(Dado);
if ((Trim(Dado) <> ´´) and
(Length(Dado) = 11)) then
begin
wdv := StrToInt(copy(Dado,11,1));
wsoma := 0;
wm11 := 2;
for i := 1 to 10 do
begin
wsoma := wsoma + (wm11 * StrToInt(Copy(Dado,11 -i, 1)));
if wm11 < 9 then
wm11 := wm11+1
else
wm11 := 2;
end;
wdigito := 11 - (wsoma mod 11);
if wdigito > 9 then
wdigito := 0;
if wdv = wdigito then
ValidaPIS := True
else
ValidaPIS := False;
end;
end;
function FillPis (s: string): string;
begin
while length(s) < 11 do
s:= ´0´+s;
result:= s;
end;
var
i,wsoma,wm11,wdv,wdigito: integer;
begin
ValidaPIS := False;
Dado := FillPis(Dado);
if ((Trim(Dado) <> ´´) and
(Length(Dado) = 11)) then
begin
wdv := StrToInt(copy(Dado,11,1));
wsoma := 0;
wm11 := 2;
for i := 1 to 10 do
begin
wsoma := wsoma + (wm11 * StrToInt(Copy(Dado,11 -i, 1)));
if wm11 < 9 then
wm11 := wm11+1
else
wm11 := 2;
end;
wdigito := 11 - (wsoma mod 11);
if wdigito > 9 then
wdigito := 0;
if wdv = wdigito then
ValidaPIS := True
else
ValidaPIS := False;
end;
end;
Responder
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)