![]() |
|
|
#1
|
|||
|
|||
|
надо чтобы в edit3 не записывался ноль и сделать,чтобы выводило сообщение деление на ноль
Код:
procedure TForm1.RadioGroup1Click(Sender: TObject);
var c,a,b:real;
begin
if (Edit1.text='') or (Edit2.text='') then
ShowMessage('введите числа')
else
begin a:=StrTofloat(Edit1.Text);
b:=StrTofloat(Edit2.text);
end;
if RadioGroup1.ItemIndex=0 then begin
c:=a+b;
Edit3.text:=floattostr(c);
end else if RadioGroup1.ItemIndex=1 then begin
c:=a-b;
Edit3.text:=floattostr(c);
end else if RadioGroup1.ItemIndex=2 then
begin c:=0;
c:=a*b;
Edit3.text:=floattostr(c);
end else begin
c:=a/b;
Edit3.text:=floattostr(c);
end;
end;
end.
|
|
#2
|
||||
|
||||
|
перед тем, как делить проверяйте на то на что вы собственно делите
т.е.: если b=0 то сообщение(деление на ноль) иначе (все выполняемые действия) |