unit Betrag1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Buttons, StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
Label2: TLabel;
Label3: TLabel;
Button1: TButton;
BitBtn1: TBitBtn;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
var Zahl, Betrag: Real;
procedure TForm1.Button1Click(Sender: TObject);
begin
(* Einlesen der Zahl *)
Zahl := StrToFloat(Edit1.Text);
Betrag := Zahl;
(* Entscheidung, ob Vorzeichen geändert werden muss *)
if Zahl < 0 then Betrag := -Zahl;
(* Ausgabe des Betrages *)
Label3.Caption := FloatToStr(Betrag);
end;
end.