Mam taki kodzik, chodzi w nim o to ze mam StringGrida z 9-ma pozycjami i w
każdych z trzech pozycji jest liczone pole trójkąta zgodnie ze wzorem
Herona, Liczby są losowane w komurkach StringGida
Z radiogrupa wybieram ktora sekcja ma byc obliczona i wyświetlona w Edit1
pytanie moje wiąże sie dlaczego jak program uruchamiam
i wybieram np. druga sekcje to mam błąd "EnvalidOp czyli niewłaściwy operand
lub operacja zmiennoprzecinkowa" czemu tak sie dzieje i jak "skrócic" wynik
do np 4 miejsca po przecinku ???
procedure TForm1.Button2Click(Sender: TObject);
var
i:integer;
begin
for i:=0 to 8 do
begin
StringGrid1.Cells[i,1]:=IntToStr(Random(50)+1);
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
StringGrid1.Cells[0,0]:='a';
StringGrid1.Cells[1,0]:='b';
StringGrid1.Cells[2,0]:='c';
StringGrid1.Cells[3,0]:='a';
StringGrid1.Cells[4,0]:='b';
StringGrid1.Cells[5,0]:='c';
StringGrid1.Cells[6,0]:='a';
StringGrid1.Cells[7,0]:='b';
StringGrid1.Cells[8,0]:='c';
end;
procedure TForm1.Button1Click(Sender: TObject);
var
j:integer;
begin
for j:=0 to 8 do
begin
StringGrid1.Cells[j,1]:='';
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
var
p1,p2,p3:extended;
e1,f1,g1,h1,i1,j1,k1,l1,m1:integer;
begin
e1:=StrToInt(StringGrid1.Cells[0,1]);
f1:=StrToInt(StringGrid1.Cells[1,1]);
g1:=StrToInt(StringGrid1.Cells[2,1]);
h1:=StrToInt(StringGrid1.Cells[3,1]);
i1:=StrToInt(StringGrid1.Cells[4,1]);
j1:=StrToInt(StringGrid1.Cells[5,1]);
k1:=StrToInt(StringGrid1.Cells[6,1]);
l1:=StrToInt(StringGrid1.Cells[7,1]);
m1:=StrToInt(StringGrid1.Cells[8,1]);
//------- Pole trojkata----------------
p1:=(e1+f1+g1)/2;
p2:=(h1+i1+j1)/2;
p3:=(k1+l1+m1)/2;
try
case RadioGroup1.ItemIndex of
0: Edit1.Text:=FloatToStr(Sqrt(p1*(p1-e1)(p1-f1)(p1-g1)));
1: Edit1.Text:=FloatToStr(Sqrt(p2*(p2-h1)(p2-i1)(p2-j1)));
2: Edit1.Text:=FloatToStr(Sqrt(p3*(p3-k1)(p3-l1)(p3-m1)));
end;
except
end;
end;
{glowa} ---= pozdrawiam Oskar =- (delphi 6 GG:2792614)