Essa é simples... só é grande!

Delphi

25/09/2003

ESTOU USANDO A SEGUINTE INSTRUÇÃO PARA EFETUAR UM PEQUENO CÁLCULO:

procedure TFrmAluno.NavegadorClick(Sender: TObject; Button: TNavigateBtn);
var
total: Double;
Contador: Integer;
begin
DataModule1.TblAluno_Disciplina.First;
While Not DataModule1.TblAluno_Disciplina.Eof Do
Begin
total:= total + StrToFloat(DataModule1.TblAluno_DisciplinaMEDIA.Value);
DataModule1.TblAluno_Disciplina.Next;
lblSoma.Caption:= FloatToStr(total);
lblcontador.Caption:= InttoStr(DataModule1.TblAluno_Disciplina.RecordCount);
lblResultado.Caption:= FloatToStr(total / Contador);
End;

end;

O PROBLEMA É QUE ELE NÃO ESTÁ DANDO O RESULTADO CORRETO; POR EXEMPLO:
NO 1º REGISTRO lblContador É IGUAL A 13 E lblSoma É IGUAL A 107,9!
O RESULTADO DE lblResultado DEVERIA SER: 8,7

O QUE ESTÁ ERRADO?

UM OUTRO PROBLEMA É QUE NO ITEM ´blAluno_DisciplinaMEDIA´ ALGUNS VALORES SÃO IGUAIS A
´ - ´ E ELE DIZ: ... ´ - ´ IS NOT A VALID FLOATING POINT VALUE

OBRIGADO PELA GRANDE AJUDA !


Alexandretavares

Alexandretavares

Curtidas 0

Respostas

Machado

Machado

25/09/2003

ao invés de de usar as variaveis como integer utilize como real ex.:

var
total: double;
contador:real;

quanto ao erro o sistema está te informando que caracter ´-´ não é um caracter númerico, para evitar isso você deve proteger o campo para que só seje digitado números.

falow..


GOSTEI 0
POSTAR