Delphi-PRAXiS
Seite 4 von 4   « Erste     234   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Lotto programm (https://www.delphipraxis.net/105237-lotto-programm.html)

ScrollbarKopf 18. Dez 2007 16:24

Re: Lotto programm
 
[Pascal Fehler] Unit1.pas(79): E2014 Anweisung erforderlich, aber Ausdruck vom Typ 'Integer' gefunden
[Pascal Fehler] Unit1.pas(80): E2014 Anweisung erforderlich, aber Ausdruck vom Typ 'Integer' gefunden
[Pascal Fehler] Unit1.pas(81): E2014 Anweisung erforderlich, aber Ausdruck vom Typ 'Integer' gefunden
[Pascal Fehler] Unit1.pas(82): E2014 Anweisung erforderlich, aber Ausdruck vom Typ 'Integer' gefunden
[Pascal Fehler] Unit1.pas(83): E2014 Anweisung erforderlich, aber Ausdruck vom Typ 'Integer' gefunden
[Pascal Fehler] Unit1.pas(84): E2014 Anweisung erforderlich, aber Ausdruck vom Typ 'Integer' gefunden

Delphi-Quellcode:
richtige :=0;
if StrToInt( edit1.text) = StrToInt( edit7.text) then inc (richtige);
if StrToInt( Edit2.text) = StrToInt( Edit8.text) then inc (richtige);
if StrToInt( Edit3.text) = StrToInt( Edit9.text) then inc (richtige);
if StrToInt( Edit4.text) = StrToInt( Edit10.text) then inc (richtige);
if StrToInt( Edit5.text) = StrToInt( Edit11.text) then inc (richtige);
if StrToInt( Edit6.text) = StrToInt( Edit12.text) then inc (richtige);

if richtige = 6 then showmessage ('Sie haben Gewonnen');

if StrToInt( Edit1.text) <> StrToInt( Edit7.text) then (falsche);
if StrToInt( Edit2.text) <> StrToInt( Edit8.text) then (falsche);
if StrToInt( Edit3.text) <> StrToInt( Edit9.text) then (falsche);
if StrToInt( Edit4.text) <> StrToInt( Edit10.text) then (falsche);
if StrToInt( Edit5.text) <> StrToInt( Edit11.text) then (falsche);
if StrToInt( Edit6.text) <> StrToInt( Edit12.text) then (falsche);

if falsche =6 then showmessage ('Sie haben leider verloren');

Jelly 18. Dez 2007 16:26

Re: Lotto programm
 
Kannst du einfach mal deinen code selber nochmal lesen, anstatt ihn blind zum x-ten Male wieder hier reinzuposten, damit wir den Fehler wieder suchen sollen...

Lies mal diese Zeile, und überlege mal kurz, was daran wohl nicht stimmt:
Delphi-Quellcode:
if StrToInt( Edit1.text) <> StrToInt( Edit7.text) then (falsche);

ScrollbarKopf 18. Dez 2007 16:28

Re: Lotto programm
 
sorry

Progman 18. Dez 2007 16:33

Re: Lotto programm
 
und "falsche" ebenfalls vorher auf null setzen, damit nicht irgendwas zufälliges drin steht und dann 5362 rauskommt. :lol: ;)

ScrollbarKopf 18. Dez 2007 16:50

Re: Lotto programm
 
Thx für die guten tipps

DeddyH 18. Dez 2007 17:04

Re: Lotto programm
 
Ich hab da auch noch eine Lösung:
Delphi-Quellcode:
unit Unit1;

interface

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

type
  TZahlen = set of byte;

  TForm1 = class(TForm)
    Edit1: TEdit;
    Edit2: TEdit;
    Edit3: TEdit;
    Edit4: TEdit;
    Edit5: TEdit;
    Edit6: TEdit;
    Button1: TButton;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private-Deklarationen }
    Zahlen: TZahlen;
    procedure Ziehung;
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}


procedure TForm1.Ziehung;
var Zahl, i: byte;
begin
  Zahlen := [];
  for i := 1 to 6 do
    begin
      repeat
        Zahl := Random(45) + 1;
      until not (Zahl in Zahlen);
      include(Zahlen,Zahl);
    end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Randomize;
end;

procedure TForm1.Button1Click(Sender: TObject);
var Treffer: byte;
begin
  Ziehung;
  Treffer := 0;
  if (StrToIntDef(Edit1.Text,0) in Zahlen) then inc(Treffer);
  if (StrToIntDef(Edit2.Text,0) in Zahlen) then inc(Treffer);
  if (StrToIntDef(Edit3.Text,0) in Zahlen) then inc(Treffer);
  if (StrToIntDef(Edit4.Text,0) in Zahlen) then inc(Treffer);
  if (StrToIntDef(Edit5.Text,0) in Zahlen) then inc(Treffer);
  if (StrToIntDef(Edit6.Text,0) in Zahlen) then inc(Treffer);
  ShowMessage(Format('%d Richtige',[Treffer]));
end;

end.
[edit] Ich weiß, dass man u.U. mogeln kann, indem man in alle Edits die gleiche Zahl eingibt. Aber mir ging es jetzt darum, eine Möglichkeit mit einer Menge aufzuzeigen. [/edit]

ScrollbarKopf 18. Dez 2007 17:09

Re: Lotto programm
 
ist e so ähnlcih

DeddyH 18. Dez 2007 17:14

Re: Lotto programm
 
Aber einfacher ;)


Alle Zeitangaben in WEZ +1. Es ist jetzt 10:23 Uhr.
Seite 4 von 4   « Erste     234   

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