Como posso apresentar o Resultado!

Delphi

28/04/2003

Estou com o seguinte problema:

[b:39f7c76a6e][Warning] DeloiteMain.pas(227): Return value of function ´validapis´ might be undefined[/b:39f7c76a6e]

Sei que acontece porque declarei a função como Boolean,
[b:39f7c76a6e]function validaPis(vPis : String) : boolean;[/b:39f7c76a6e]
E na procedure que quero apresentar uma menssagem fiz o seguinte

procedure TForm1.MEPisChange(Sender: TObject);
var
[b:39f7c76a6e]rPis : Boolean;[/b:39f7c76a6e]
begin
if Length(MEPis.Text) = 10 then
begin
rPis := ValidaPis(MEPis.Text);
[b:39f7c76a6e]if rPis = True then[/b:39f7c76a6e]
MessageDlg(´PIS Válido´,mtInformation,[mbOk],0)
else
MessageDlg(´PIS Inválido´,mtWarning,[mbOk],0);
MEPis.SelectAll

end;
end;

[b:39f7c76a6e]Como posso apresentar este resultado?[/b:39f7c76a6e]


Wgm8

Wgm8

Curtidas 0

Respostas

Okama

Okama

28/04/2003

Pelo erro parece que sua função não está retornando um valor.
verifique todas as saídas da função ou defina um valor padrão no inicio da função. Ex.

function validapis(texto:string):boolean;
var retorno:boolean;
begin
retorno := True;

<testes....>


result := retorno;
end;


GOSTEI 0
Wgm8

Wgm8

28/04/2003

function validaPis(vPis : String) : boolean;
var
i, wsoma, Wm11, Wdv,wdigito : Integer;
begin
if Trim(vPis) <> ´´ Then
begin
wdv := strtoint(copy(vPis, 11, 1));
wsoma := 0;
wm11 := 2;
for i := 1 to 10 do
begin
wsoma := wsoma + (wm11 *strtoint(copy(vPis,11 - I, 1)));
if wm11 < 9 then
begin
wm11 := wm11+1
end
else
begin
wm11 := 2;
end;
end;
wdigito := 11 - (wsoma MOD 11);
if wdigito > 9 then
begin
wdigito := 0;
end;
if wdv = wdigito then
begin
validaPis := true;
end
else
begin
validaPis := false;
end;
end;
end;


GOSTEI 0
Wgm8

Wgm8

28/04/2003

Eu não usei o ButtonClick

usei o Change, que é pra ele aceitar no momento da digitação.

Conforme digito um número ele fica me aparecendo a caixa de menssagem, como faço para que após digitar o último digito ele me mostre a menssagem e não a cada digito?

Até mais...


GOSTEI 0
Wgm8

Wgm8

28/04/2003

Valeu Pessoal pela Ajuda!!!


GOSTEI 0
POSTAR