AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Taschenrechner

Ein Thema von Tytomik · begonnen am 28. Feb 2011 · letzter Beitrag vom 25. Apr 2011
 
Tytomik

Registriert seit: 25. Feb 2011
24 Beiträge
 
#1

Taschenrechner

  Alt 28. Feb 2011, 13:31
Hallo,
ich habe heute einen taschenrechner prgrammiert.
Mit 2 Eingabefelder und 4 Button mit +,-,*,/ und einem label.
Es funktioniert auch alles aber ich will jetzt noch einen 5. Button machen das wenn man auf den klickt zfällig ist ob +,-,* oder / kommt.

Hier noch mal der queltext:
(Quelltext)
Delphi-Quellcode:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Label1: TLabel;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);

  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var a,b,c:Real;
begin
randomize;
Form1.Color:=random(255*255*255);
a:=strtofloat(Edit1.Text);
b:=strtofloat(Edit2.Text);
c:=a+b;
Label1.caption:=floattostr(c);
If c=10 then begin
Form1.Color:=clred;

end;
end;

procedure TForm1.Button2Click(Sender: TObject);
var a,b,c:Real;
begin
randomize;
Form1.Color:=random(255*255*255);
a:=strtofloat(Edit1.Text);
b:=strtofloat(Edit2.Text);
c:=a-b;
Label1.caption:=floattostr(c);
If c=10 then begin
Form1.Color:=clgreen;
end;
end;

procedure TForm1.Button3Click(Sender: TObject);
var a,b,c:Real;
begin
randomize;
Form1.Color:=random(255*255*255);
a:=strtofloat(Edit1.Text);
b:=strtofloat(Edit2.Text);
c:=a*b;
Label1.caption:=floattostr(c);
If c=25 then begin
Form1.Color:=clyellow;

end;
end;

procedure TForm1.Button4Click(Sender: TObject);
var a,b,c:Real;
begin
randomize;
Form1.Color:=random(255*255*255);
a:=strtofloat(Edit1.Text);
b:=strtofloat(Edit2.Text);
c:=a/b;
Label1.caption:=floattostr(c);
If c=5 then begin
Form1.Color:=clblue;

end;
end;



end.

Freue mich auf rückmeldung.

Geändert von Sharky (28. Feb 2011 um 14:04 Uhr)
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 10:08 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz