Fórum O que ha de errado nessa codigo ? #183769
23/09/2003
0
Saudações pessoal,
Tenho uma tabela onde ha pesquisas ou seja possuo 23 campos com resposta [SIM/NAO/ND] dai no final coloquei 3 campos com resultado dessa pesquisa, sendo resultado negativo com valores sim = nao e nao = nao e o resultado positivo onde dimini 23 - os valores negativos e o percentual da soma do resultado que é 100 = 100¬ dai no codigo abaixo a logica esta certa esta me retornando o resultado so q qdo edito e altero algum DBCOMBOBOX COM SIM OU NAO ELE ME RETORNA UM RESULTADO QUE NAO TEM NDA A VER. O QUE HA DE ERRADO COM O CODIGO ABAIXO ? POIS AS VARIAVEIS E OS CAMPO INICIALIZAM COM ZERO !
procedure TFrmFedAud.BitBtn1Click(Sender: TObject);
var Soma,valor,aux : Integer;
begin
Soma := 0;
Aux := 0;
DBEdit34.Text := ´0´;
DBEdit9.Text := ´0´;
DBEdit35.Text := ´0´;
if DBComboBox1.Text = ´Não´ Then
begin
Soma := Soma + 3;
inc(aux);
end;
if DBComboBox2.Text =´Não´ Then
begin
Soma := Soma + 3;
inc(aux);
end;
if DBComboBox3.Text = ´Não´ Then
begin
Soma := Soma + 3;
inc(aux);
end;
if DBComboBox4.Text = ´Não´ Then
begin
Soma := Soma + 3;
inc(aux);
end;
if DBComboBox5.Text = ´Sim´ Then
begin
Soma := Soma + 4;
inc(aux)
end;
if DBComboBox6.Text = ´Não´ Then
begin
Soma := Soma + 3;
inc(aux);
end;
if DBComboBox7.Text = ´Não´ Then
begin
Soma := Soma + 3;
inc(aux);
end;
if DBComboBox8.Text = ´Sim´ Then
begin
Soma := Soma + 4;
inc(aux);
end;
if DBComboBox9.Text = ´Não´ Then
begin
Soma := Soma + 3;
inc(aux);
end;
if DBComboBox10.Text = ´Não´ Then
begin
Soma := Soma + 3;
inc(aux);
end;
if DBComboBox11.Text = ´Não´ Then
begin
Soma := Soma + 3;
inc(aux);
end;
if DBComboBox12.Text = ´Não´ Then
begin
Soma := Soma + 3;
inc(aux);
end;
if DBComboBox13.Text = ´Não´ Then
begin
Soma := Soma + 4;
inc(aux);
end;
if DBComboBox14.Text = ´Não´ Then
begin
Soma := Soma + 4;
inc(aux);
end;
if DBComboBox15.Text = ´Não´ Then
begin
Soma := Soma + 4;
inc(aux);
end;
if DBComboBox16.Text = ´Não´ Then
begin
Soma := Soma + 4;
inc(aux);
end;
if DBComboBox17.Text = ´Não´ Then
begin
Soma := Soma + 4;
inc(aux);
end;
if DBComboBox18.Text = ´Não´ Then
begin
Soma := Soma + 4;
inc(aux);
end;
if DBComboBox19.Text = ´Não´ Then
begin
Soma := Soma + 4;
inc(aux);
end;
if DBComboBox20.Text = ´Não´ Then
begin
Soma := Soma + 4;
inc(aux);
end;
if DBComboBox21.Text = ´Sim´ Then
begin
Soma := Soma + 10;
inc(aux);
end;
if DBComboBox22.Text = ´Sim´ Then
begin
Soma := Soma + 10;
inc(aux);
end;
if DBComboBox23.Text = ´Sim´ Then
begin
Soma := Soma + 10;
inc(aux);
end;
Valor := (100 - Soma);
DBEdit34.Text := IntToStr(aux);
DBEdit9.Text := IntToStr(23 - aux);
DBEdit35.Text := FloatToStr((Valor*100)/100);
BitBtn1.Enabled := False;
DBEdit9.Enabled := False;
DBEdit35.Enabled := False;
DBEdit34.Enabled := False;
end;
Tenho uma tabela onde ha pesquisas ou seja possuo 23 campos com resposta [SIM/NAO/ND] dai no final coloquei 3 campos com resultado dessa pesquisa, sendo resultado negativo com valores sim = nao e nao = nao e o resultado positivo onde dimini 23 - os valores negativos e o percentual da soma do resultado que é 100 = 100¬ dai no codigo abaixo a logica esta certa esta me retornando o resultado so q qdo edito e altero algum DBCOMBOBOX COM SIM OU NAO ELE ME RETORNA UM RESULTADO QUE NAO TEM NDA A VER. O QUE HA DE ERRADO COM O CODIGO ABAIXO ? POIS AS VARIAVEIS E OS CAMPO INICIALIZAM COM ZERO !
procedure TFrmFedAud.BitBtn1Click(Sender: TObject);
var Soma,valor,aux : Integer;
begin
Soma := 0;
Aux := 0;
DBEdit34.Text := ´0´;
DBEdit9.Text := ´0´;
DBEdit35.Text := ´0´;
if DBComboBox1.Text = ´Não´ Then
begin
Soma := Soma + 3;
inc(aux);
end;
if DBComboBox2.Text =´Não´ Then
begin
Soma := Soma + 3;
inc(aux);
end;
if DBComboBox3.Text = ´Não´ Then
begin
Soma := Soma + 3;
inc(aux);
end;
if DBComboBox4.Text = ´Não´ Then
begin
Soma := Soma + 3;
inc(aux);
end;
if DBComboBox5.Text = ´Sim´ Then
begin
Soma := Soma + 4;
inc(aux)
end;
if DBComboBox6.Text = ´Não´ Then
begin
Soma := Soma + 3;
inc(aux);
end;
if DBComboBox7.Text = ´Não´ Then
begin
Soma := Soma + 3;
inc(aux);
end;
if DBComboBox8.Text = ´Sim´ Then
begin
Soma := Soma + 4;
inc(aux);
end;
if DBComboBox9.Text = ´Não´ Then
begin
Soma := Soma + 3;
inc(aux);
end;
if DBComboBox10.Text = ´Não´ Then
begin
Soma := Soma + 3;
inc(aux);
end;
if DBComboBox11.Text = ´Não´ Then
begin
Soma := Soma + 3;
inc(aux);
end;
if DBComboBox12.Text = ´Não´ Then
begin
Soma := Soma + 3;
inc(aux);
end;
if DBComboBox13.Text = ´Não´ Then
begin
Soma := Soma + 4;
inc(aux);
end;
if DBComboBox14.Text = ´Não´ Then
begin
Soma := Soma + 4;
inc(aux);
end;
if DBComboBox15.Text = ´Não´ Then
begin
Soma := Soma + 4;
inc(aux);
end;
if DBComboBox16.Text = ´Não´ Then
begin
Soma := Soma + 4;
inc(aux);
end;
if DBComboBox17.Text = ´Não´ Then
begin
Soma := Soma + 4;
inc(aux);
end;
if DBComboBox18.Text = ´Não´ Then
begin
Soma := Soma + 4;
inc(aux);
end;
if DBComboBox19.Text = ´Não´ Then
begin
Soma := Soma + 4;
inc(aux);
end;
if DBComboBox20.Text = ´Não´ Then
begin
Soma := Soma + 4;
inc(aux);
end;
if DBComboBox21.Text = ´Sim´ Then
begin
Soma := Soma + 10;
inc(aux);
end;
if DBComboBox22.Text = ´Sim´ Then
begin
Soma := Soma + 10;
inc(aux);
end;
if DBComboBox23.Text = ´Sim´ Then
begin
Soma := Soma + 10;
inc(aux);
end;
Valor := (100 - Soma);
DBEdit34.Text := IntToStr(aux);
DBEdit9.Text := IntToStr(23 - aux);
DBEdit35.Text := FloatToStr((Valor*100)/100);
BitBtn1.Enabled := False;
DBEdit9.Enabled := False;
DBEdit35.Enabled := False;
DBEdit34.Enabled := False;
end;
Jonasaf
Curtir tópico
+ 0
Responder
Posts
23/09/2003
Marcelo Saviski
Não consegui encontrar o erro mas porque: FloatToStr((Valor*100)/100);
?
(Valor*100)/100 não é igual a Valor?
?
(Valor*100)/100 não é igual a Valor?
Responder
Gostei + 0
24/09/2003
Turbo Drive
Eu já tive um problema parecido com dbcombobox uma vez. Se vc prestar bem atenção, quando vc manda gravar, os valores que estão no dbcombobox desaparecem, ficam em branco. Faça um teste: troque os dbcombobox por combobox.
Espero ter ajudado.
Espero ter ajudado.
Responder
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)