unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 =
class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Button1: TButton;
Label4: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Button2: TButton;
Label5: TLabel;
Image1: TImage;
Label6: TLabel;
Image2: TImage;
Label7: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
F, H: integer ;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
randomize;
H:=random(9)+1;
F:=random(9)+1;
label2.Caption:=IntToStr(H);
label3.Caption:=IntToStr(F);
end;
procedure TForm1.Button2Click(Sender: TObject);
var
PosBruchstrich: Integer;
EditText:
string;
Zaehler, Nenner: Double;
begin
EditText := Edit2.Text;
PosBruchstrich := Pos('
/', EditText);
if PosBruchstrich > 0
then
begin
Zaehler := StrToFloat(Copy(EditText, 1, PosBruchstrich - 1));
Nenner := StrToFloat(Copy(EditText, PosBruchstrich + 1,
Length(EditText) - PosBruchstrich));
end else
begin
Zaehler := StrToFloat(EditText);
Nenner := 1;
end;
ShowMessage('
Zähler: ' + FloatToStr(Zaehler) + #13#10 +
'
Nenner: ' + FloatToStr(Nenner));
end;
end.