Autor Beitrag
D2505
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 62
Erhaltene Danke: 18


Delphi (7 PE + Lazarus ) ;Java ( Eclipse),
BeitragVerfasst: Di 14.12.10 18:04 
hallo ich wollte ein einfachen würfel programmieren
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:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
  Zahl1:
implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  randomize;
  Zahl1 := random (100);
  Label1.Caption := FloatToStr(Zahl1);
end;

end.

aber er sagt mir beim ausführen typ erwartet aber implentation gefunden woran liegt das war ja imm automatisch erstellten quellcode drin
mfg


Moderiert von user profile iconNarses: Topic aus Sonstiges (Delphi) verschoben am Di 14.12.2010 um 17:05
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 14.12.10 18:07 
Moin!

Hast du evtl. hier etwas "vergessen": ;)
user profile iconD2505 hat folgendes geschrieben Zum zitierten Posting springen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
  Zahl1: Integer;
implementation

{$R *.dfm}
cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.

Für diesen Beitrag haben gedankt: D2505
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Di 14.12.10 18:16 
Naja, eigentlich ist eher das "Zahl1:" dort zu viel. Globale Variablen sollte man der Übersichtlichkeit wegen nach Möglichkeit vermeiden.
Deshalb:
ausblenden Delphi-Quelltext
 
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:
{ ... }
  TForm1 = class(TForm)
    Label1: TLabel;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
  Zahl1: Integer;

begin
  randomize;
  Zahl1 := random (100);
  Label1.Caption := FloatToStr(Zahl1);
end;
;-)
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: Di 14.12.10 18:21 
user profile iconjaenicke hat folgendes geschrieben Zum zitierten Posting springen:
Naja, eigentlich ist eher das "Zahl1:" dort zu viel. Globale Variablen sollte man der Übersichtlichkeit wegen nach Möglichkeit vermeiden.

Und wenn wir schon dabei sind, könnte man auch gleich sinnlose Variablen vermeiden und, was wichtiger ist, typrichtig arbeiten:
ausblenden Delphi-Quelltext
 
27:
28:
29:
30:
31:
{ ... }
procedure TForm1.Button1Click(Sender: TObject);
begin
  randomize;
  Label1.Caption := IntToStr(random(100));
end;
;-)

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."

Für diesen Beitrag haben gedankt: D2505
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Di 14.12.10 18:24 
Herauskommen tut aber das selbe. :P

Aber du hast ja Recht. ;-)
D2505 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 62
Erhaltene Danke: 18


Delphi (7 PE + Lazarus ) ;Java ( Eclipse),
BeitragVerfasst: Mi 15.12.10 17:54 
danke jetzt tut es mein würfel programm
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5284
Erhaltene Danke: 27

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Mi 15.12.10 18:09 
Ich sehe irgendwie gerade nicht, was das Programm mit einem Würfel zu tun hat. :?
Wenn damit ein Spielwürfel gemeint ist, so ist das nicht ganz richtig, da ein W100 aufgrund seiner Form nicht ganz ideal ist. :mrgreen:
D2505 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 62
Erhaltene Danke: 18


Delphi (7 PE + Lazarus ) ;Java ( Eclipse),
BeitragVerfasst: Sa 18.12.10 19:33 
ja das habe ich schon angepasst
falst du random(100) meinst