Fórum Problemas com comando IF #559450
20/07/2016
0
procedure TfrmAvaliacao.btnWeightsClick(Sender: TObject);
var
I,j: Integer;
edt:TIWEdit;
sumcrit:double;
aux:string;
begin
for I := 0 to n_crit - 1 do
begin
edt:=TIWEdit(rgnweights.FindComponent('edtCel'+idcrit[i]));
if edt.Text='' then
begin
WebApplication.ShowMessage('Please, fill in the fields with the weights of the criteria');
Abort;
end;
sumcrit:=sumcrit+StrToFloat(edt.Text);
end;
if sumcrit<>1 then
begin
WebApplication.ShowMessage('The sum of the criteria must be 1');
Abort;Nessa passagem, eu desejo que o aplicativo receba os valores inseridos em certos edits, some esses valores na variável sumcrit e desejo que essa soma seja igual a 1. Caso essa condição não seja verificada, deve-se mandar uma mensagem ao usuário e abortar o procedimento. O meu problema é que mesmo em situações onde o valor de sumcrit é igual a 1, o procedimento insiste em entrar no "IF" e abortar o procedimento. Alguem sabe de algo que eu esteja fazendo de incorreto? Obrigado pela atenção
Luiz Neto
Curtir tópico
+ 0Posts
20/07/2016
Raylan Zibel
Gostei + 0
20/07/2016
Luiz Neto
Gostei + 0
20/07/2016
Huidemar Costa
procedure TfrmAvaliacao.btnWeightsClick(Sender: TObject);
var
I,j: Integer;
edt:TIWEdit;
um,
sumcrit:double;
aux:string;
begin
for I := 0 to n_crit - 1 do
begin
edt:=TIWEdit(rgnweights.FindComponent('edtCel'+idcrit[i]));
if edt.Text='' then
begin
WebApplication.ShowMessage('Please, fill in the fields with the weights of the criteria');
Abort;
end;
sumcrit:=sumcrit+StrToFloat(edt.Text);
end;
um := 1; // coloque o valor em uma váriavel
if sumcrit<>um then
begin
WebApplication.ShowMessage('The sum of the criteria must be 1');
Abort;
Gostei + 0
20/07/2016
Raylan Zibel
if sumcrit <> 1.0 then begin end;
Gostei + 0
29/07/2016
Luiz Neto
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)