Einzelnen Beitrag anzeigen

ItsMe1

Registriert seit: 31. Jan 2013
15 Beiträge
 
#1

Nur das größte Ergebnis wird angegeben (Rechner mit Checkbox und Radiobox)

  Alt 1. Feb 2013, 18:14
Hey Leute,
ich hab noch eine Frage...
Ich möchte gerne das mein "Taschenrechner" die Editfelder mit dem dazugehörigen Hacken in der Checkbox addiert.
Mein Problem ist es das immer nur zwei zahlen zusammengerechnet werden oder halt nicht nur die wo ein hacken in der Checkbox ist ....
Hier der Code:
Code:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    CheckBox1: TCheckBox;
    CheckBox2: TCheckBox;
    CheckBox3: TCheckBox;
    CheckBox4: TCheckBox;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button2Click(Sender: TObject);
begin
  if radiobutton1.Checked = true and Checkbox1.Checked = true and Checkbox2.Checked =true then
    begin
      label7.Caption:= floattostr(strtofloat(edit1.Text)+strtofloat(edit2.Text));
    end;

  if radiobutton1.Checked = true and checkbox1.Checked =true and checkbox3.Checked =true then
    begin
      label7.caption:= floattostr(strtofloat(edit1.Text)+strtofloat(edit3.Text));
    end;

  if radiobutton1.Checked = true and Checkbox1.Checked = true and Checkbox4.Checked =true then
    begin
      label7.Caption:= floattostr(strtofloat(edit1.Text)+strtofloat(edit4.Text));
    end;

  if radiobutton1.Checked = true and checkbox2.Checked =true and checkbox3.Checked =true then
    begin
      label7.caption:= floattostr(strtofloat(edit2.Text)+strtofloat(edit3.Text));
    end;

  if radiobutton1.Checked = true and Checkbox2.Checked = true and Checkbox4.Checked =true then
    begin
      label7.Caption:= floattostr(strtofloat(edit2.Text)+strtofloat(edit4.Text));
    end;

  if radiobutton1.Checked = true and checkbox3.Checked =true and checkbox4.Checked =true then
    begin
      label7.caption:= floattostr(strtofloat(edit3.Text)+strtofloat(edit4.Text));
    end;

  if radiobutton1.Checked = true and Checkbox1.Checked = true and Checkbox2.Checked =true and Checkbox3.Checked =true then
    begin
      label7.Caption:= floattostr(strtofloat(edit1.Text)+strtofloat(edit2.Text)+strtofloat(edit3.Text));
    end;

  if radiobutton1.Checked = true and checkbox1.Checked =true and checkbox3.Checked =true and Checkbox4.Checked =true then
    begin
      label7.caption:= floattostr(strtofloat(edit1.Text)+strtofloat(edit3.Text)+strtofloat(edit4.Text));
    end;

  if radiobutton1.Checked = true and Checkbox4.Checked = true and Checkbox2.Checked =true and Checkbox3.Checked =true then
    begin
      label7.Caption:= floattostr(strtofloat(edit4.Text)+strtofloat(edit2.Text)+strtofloat(edit3.Text));
    end;

  if radiobutton1.Checked = true and checkbox1.Checked =true and checkbox2.Checked =true and Checkbox3.Checked =true and Checkbox4.Checked =true then
    begin
      label7.caption:= floattostr(strtofloat(edit1.Text)+strtofloat(edit2.Text)+strtofloat(edit3.Text)+strtofloat(edit4.Text));
    end;



end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  close;
end;

end.
Vielen Dank schon mal für die Hilfe
Grüße ItsMe1
  Mit Zitat antworten Zitat