Autor Beitrag
Rokshox
Hält's aus hier
Beiträge: 4



BeitragVerfasst: Do 19.04.07 15:36 
So das wäre mein Problem wenn jemand was damit anfangen kann :')
Also das ist ein Rechenprogramm das zwei zufallszahlen generiert wobei wir auch schon bei meinem Problem wären weil es das nicht tut und mit den buttons kann mann entweder multiplitieren oder ähnliches



ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
unit Unit1123;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    procedure Label3Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
  Zahl1, Zahl2, Ergebnis: Integer;

implementation

{$R *.dfm}

procedure TForm1.Label3Click(Sender: TObject);
begin
randomize;
Zahl1 := random (100);
Zahl1 := random (100);
Label1.Caption := IntToStr(Zahl1);
Label2.Caption := IntToStr(Zahl2);
Label3.Caption := 'Wähle die Rechenart';
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
Ergebnis := Zahl1 + Zahl2;
Label3.Caption :=
 'Ergebnis der Addition: ' + IntToStr(Ergebnis);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
Ergebnis := Zahl1 - Zahl2;
Label3.Caption :=
 'Ergebnis der Subtraktion: ' + IntToStr(Ergebnis);
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
Ergebnis := Zahl1 * Zahl2;
Label3.Caption :=
 'Ergebnis der Multiplikation: ' + IntToStr(Ergebnis);
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
Ergebnis := Zahl1 div Zahl2;
Label3.Caption :=
 'Ergebnis der Division: ' + IntToStr(Ergebnis);
end;

end.


Moderiert von user profile iconraziel: Delphi-Tags hinzugefügt
Schüler
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 183



BeitragVerfasst: Do 19.04.07 15:44 
[Peinlich]Ich bin aber auch doof[/Peinlich]

_________________
Das Leben ist ein Scheiß Spiel aber es hat eine hammer Grafik und grenzt an realismuss.


Zuletzt bearbeitet von Schüler am Do 19.04.07 16:07, insgesamt 1-mal bearbeitet
FiceGoesDelphi
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 485

Win XP Prof
Delphi 2006
BeitragVerfasst: Do 19.04.07 15:46 
Erstmal bitte ich dich deinen Code in [Delphi] *hier dein Code* [/Delphi] Tags zu setzen ;)
Ich schau mal ob ich was finde! :)

EDIT:
Du schreibst:

Zahl1 := random (100);
Zahl1 := random (100);

Versuchs dochmal mit Zahl1 und Zahl2 ;)

_________________
<(^^<) <(^^)> (>^^)>
===================
Rokshox Threadstarter
Hält's aus hier
Beiträge: 4



BeitragVerfasst: Do 19.04.07 17:46 
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
unit unit33testmalwieder;

interface

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

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Button4: TButton;
    procedure Label3Click(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure Button4Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
  Zahl1, Zahl2, Ergebnis: Integer;

implementation

{$R *.dfm}

procedure TForm1.Label3Click(Sender: TObject);
begin
 randomize;
 Zahl1 := random (100);                 //Habe ich hier einen fehler?//
 Zahl2 := random (100);
 Label1.Caption := IntToStr(Zahl1);
 Label2.Caption := IntToStr(Zahl2);
 Label3.Caption := 'Wähle die Rechenart!';
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
Ergebnis := Zahl1 + Zahl2;
Label3.Caption :=
 'Ergebnis der Addition: ' + IntToStr(Ergebnis);

end;

procedure TForm1.Button2Click(Sender: TObject);
begin
Ergebnis := Zahl1 - Zahl2;
Label3.Caption :=
 'Ergebnis der Subtraktion: ' + IntToStr(Ergebnis);

end;

procedure TForm1.Button3Click(Sender: TObject);
begin
Ergebnis := Zahl1 * Zahl2;
Label3.Caption :=
 'Ergebnis der Multiplikation: ' +IntToStr(Ergebnis);

end;

procedure TForm1.Button4Click(Sender: TObject);
begin
Ergebnis :=Zahl1 div Zahl2;
Label3.Caption :=
 'Ergebnis der Division: ' +IntToStr(Ergebnis);
end;

end.



Ja sry so das war das Prob sry bin noch ein Anfänger!
Aber der zeigt mir nicht die zu generierenden zahlen an!
Christian V.
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 311

Win Xp Prof
Turbo Delphi 2005
BeitragVerfasst: Do 19.04.07 17:48 
Was nun, was genau funktioniert denn nicht? Bei mir funktioniert alles.

_________________
Hardware runs the world, software controls the hardware, code generates software - Have You already coded today?
Rokshox Threadstarter
Hält's aus hier
Beiträge: 4



BeitragVerfasst: Do 19.04.07 18:54 
Titel: Bei mir steht da oben dann aber 0!!
Bei mir steht da oben dann aber 0!!
Magic J
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 66

WinXP Prof., Vista
Delphi6, Delphi 2009, Java(Eclipse), C++, Basic
BeitragVerfasst: Do 19.04.07 19:34 
Hi

Bist du dir sicher, dass du das ausführen willst, wenn du auf des "Label3" klickst?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TForm1.Label3Click(Sender: TObject);  
begin  
 randomize;  
 Zahl1 := random (100); 
 Zahl2 := random (100);  
 Label1.Caption := IntToStr(Zahl1);  
 Label2.Caption := IntToStr(Zahl2);  
 Label3.Caption := 'Wähle die Rechenart!';  
end;


und nicht vielleicht aufm button...
oder dachtest du vielleicht, dass du es in FormCreate drinnen hast?
ausblenden Delphi-Quelltext
1:
procedure TForm1.FormCreate(Sender: TObject);					


Gruß Jonas
Rokshox Threadstarter
Hält's aus hier
Beiträge: 4



BeitragVerfasst: Fr 20.04.07 12:51 
Damit ihr wisst was gemeint ist ist das projekt im anhang
Einloggen, um Attachments anzusehen!
Tilo
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 1098
Erhaltene Danke: 13

Win7 geg. WInXP oder sogar Win98
Rad2007
BeitragVerfasst: Fr 20.04.07 13:45 
Zumindest Unit1 wird noch benötigt.
Im Anhang ist ein Beispiel für ein Project welches in einem leeren Ordner gespeichert wurde und es einmal compiliert wurde.
Bis auf die Exe wären die anderen Dateien hilfreich und (teils) nötig.
Einloggen, um Attachments anzusehen!
Magic J
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 66

WinXP Prof., Vista
Delphi6, Delphi 2009, Java(Eclipse), C++, Basic
BeitragVerfasst: Fr 20.04.07 19:45 
Hi,

ich habe mal zum testen deinen Quellcode kopiert und nen eigenes Form mit 4 Button und 3 Labels erstellt,
sowie den button´s und Label3 die jeweiligen OnClick-Procduren zugewiesen!

Bei mir läuft dein Programm einwandfrei!

Man startet das Programm, klickt auf die Label3 und schon erscheinen in Label1 und Label2 zwei Zufallszahlen, die man dann mit den einzelnen Button´s miteinander verrechnen kann und das Ergebnis erscheint in Label3...

Wo ist dein Problem???

Ich hätte jedoch statt dem Label3Click diese Anweisungen lieber in ne OnClick-Procedure eines fünften neuen button, der dann also immer neue Zahlen generiert!

Oder (wenn du nur eimalige Zahlen willst) in die "FormCreate" halt rein.

Ansonsten gibt´s an dem Code keinerlei Fehler!!! :)
(Da war nur der, den "FiceGoesDelphi" schon korigiert hat)

Schönen Gruß, Jonas