Einzelnen Beitrag anzeigen

kamel08
(Gast)

n/a Beiträge
 
#38

Re: In Delphi ein Kapital mit einer ListBox berechnen

  Alt 29. Sep 2009, 19:29
unit Unit1;

interface

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

type
TForm1 = class(TForm)
EdtKapital: TEdit;
EdtZinssatz: TEdit;
EdtErgebnis: TEdit;
LstBox: TListBox;
BtnBerechnen: TButton;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Button1: TButton;
procedure BtnBerechnenClick(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;

var
Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.BtnBerechnenClick(Sender: TObject);
var startkapital,zinssatz:extended; // kapital umdefiniert in 'startkapital'
kapital:extended; // für das Ergebnis
begin
startkapital := StrToFloat(edtkapital.text);

Zinssatz := StrToFloat(edtzinssatz.text);
Zinssatz := (zinssatz/100);

kapital := startkapital + (startkapital * Zinssatz);

edtergebnis.Text := FloatToStr(kapital);

LstBox.Items.Add(FloatToStr(kapital));
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
edtkapital.text := '';
edtzinssatz.text := '';
edtergebnis.Text := '';
end;

end.
  Mit Zitat antworten Zitat