Autor Beitrag
master5
Hält's aus hier
Beiträge: 10



BeitragVerfasst: Di 01.02.05 15:56 
hi ich habe hier ein problem natürlich ist das programm noch nicht fertig aber wenn ich hier das passwort eingebe dann müsste doch eigentlich im label1 #Richtig# erscheinen oder tut aber nicht bitte helft mir :?: :? unit pwknacker1;
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:
interface

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

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Button1: TButton;
    Button2: TButton;
    procedure FormCreate(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;
const
  max = 10;

var
  Form1: TForm1;
  passwort: array[1..max] of string;
  nr: integer;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
begin
  randomize;
  passwort[1] := '5976';
  passwort[2] := 'idiot';
  passwort[3] := 'weis nicht';
  passwort[4] := 'x-mas';
  passwort[5] := 'thematrix';
  passwort[6] := 'simpsons';
  passwort[7] := 'welcome';
  passwort[8] := 'derwixxer';
  passwort[9] := 'bene';
  passwort[10] := 'matze';
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
 if
   nr = random (max) +1 then
    label1.caption := 'Richtig!!!';
  end;

end.


danke schon mal im vorraus :wink:

Moderiert von user profile iconGausi: Delphi-Tags hinzugefügt.


Zuletzt bearbeitet von master5 am Mi 02.02.05 15:56, insgesamt 1-mal bearbeitet
OneOfTen
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Di 01.02.05 16:09 
Ich versteh das ganze nicht, aber die if-Bedingung
ausblenden Delphi-Quelltext
1:
if nr = random (max) +1					

wird doch nie erfüllt, weil nr nicht initialisiert wird.
st-matze
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 138

Win 3.11, Win 95, Win 98, Win XP
D7 Ent, D6 Pers, (D5 Pers)
BeitragVerfasst: Di 01.02.05 16:13 
1. benutze delphi tags. dann kann man deinien code auch sinnvoll lesen
2. Stil. benenne deine objekte und variablen sinnvoll (button1, button2 sind keine sinnvollen bezeichner
3. Sinnvolle überschriften deiner Threads
4. es gibt debugger
5. Was is das :?
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
procedure TForm1.Button2Click(Sender: TObject); 
begin 
if nr = random (max) +1 then 
  label1.caption := 'Richtig!!!'
end;

Eine Variable (nr), die nie gesetzt wird und somit immer 0 ist, wird mit einem nicht vorauszusehenden Zufallswert zwischen 1 und 10 (random(max)+1) verglichen. Wann soll da dann bitte mal was rauskommen?!?


st-matze
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8549
Erhaltene Danke: 478

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Di 01.02.05 16:13 
Hallo,

Bitte wähle doch einen etwas aussagekäftigeren Titel für dein Problem. Damit man schon vor dem Lesen des ganzen Beitrags weiß, worum es im Groben geht.

Danke.

_________________
We are, we were and will not be.
master5 Threadstarter
Hält's aus hier
Beiträge: 10



BeitragVerfasst: Di 01.02.05 18:54 
:oops: sorry bin halt noch neu beim programmieren mit delphie :oops:
ich hab erst das 5 kapitel durchgemacht von dem buch :wink:


ps. hätte mir das da oben helfen sollen :?: :?: :?:
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Di 01.02.05 18:58 
Hallo!

Ich möchte Dich nochmals bitten, den Titel Deines Beitrages zu ändern. Klicke dazu im ersten Beitrag auf "Edit". Danke! :-)

Haben die Antworten denn nun geholfen?

MfG
Christian

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
Sprint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 849



BeitragVerfasst: Di 01.02.05 18:58 
Du musst den Inhalt von Edit1 mit deinem Array (da wo die Passwörter drinstehen) vergleichen.

_________________
Ciao, Sprint.
Radioactive
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 179

Win 98, Win XP Home SP2
D3 Prof, D7 Pers, D2005 Pers
BeitragVerfasst: Di 01.02.05 20:08 
Du willst doch mit deinem Programm überprüfen, ob der Nutzer eines der in dem Array angegebenen Passwörter eingegeben hat, oder?
Denn das was du als erstes gepostet hat, wählt eine zufällige Zahl aus, vergleichst sie mit "nr", nr hat jedoch keinen Wert, und gibst im Falle (was nie eintreten wird), "Richtig!" aus. Warum willst du Random() verwenden? Das macht doch keinen Sinn.

So könntest du eine Passwortübeprüfung realisieren:
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:
interface

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

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Button1: TButton;
    Button2: TButton;
    procedure FormCreate(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;
const
  max = 10;

var
  Form1: TForm1;
  passwort: array[1..max] of string;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
begin
  passwort[1] := '5976';
  passwort[2] := 'idiot';
  passwort[3] := 'weis nicht';
  passwort[4] := 'x-mas';
  passwort[5] := 'thematrix';
  passwort[6] := 'simpsons';
  passwort[7] := 'welcome';
  passwort[8] := 'derwixxer';
  passwort[9] := 'bene';
  passwort[10] := 'matze';
end;

procedure TForm1.Button2Click(Sender: TObject);
var i: Integer;
begin
  for i := 1 to 10 do
  begin
    if Edit1.Text = passowrt[i] then
      Label1.Caption := 'Richtig!';
  end;
end;

end.

_________________
Radioactive
"Wer scrollt, verliert!" Matthias Stein, Informatiklehrer am GG
master5 Threadstarter
Hält's aus hier
Beiträge: 10



BeitragVerfasst: Mi 02.02.05 16:00 
danke vielmals jetzt weis ich was ich machen muss :oops:
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 02.02.05 16:13 
aber ich glaube dass er möchte dass das passwort erst durch zufall ausgewählt wird dann würde ich das so machen:

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:
interface  

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

 
type  
  TForm1 = class(TForm)  
    Edit1: TEdit;  
    Label1: TLabel;  
    Label2: TLabel;  
    Button1: TButton;  
    Button2: TButton;  
    procedure FormCreate(Sender: TObject);  
    procedure Button2Click(Sender: TObject);  
  private  
    { Private-Deklarationen }  
  public  
    { Public-Deklarationen }  
  end;  
const  
  max = 10;  

 
var  
  Form1: TForm1;  
  passwort: array[1..max] of string;  
  rpw: string;

 
implementation  

 
{$R *.DFM}  

 
procedure TForm1.FormCreate(Sender: TObject);  
begin  
  randomize;
  passwort[1] := '5976';  
  passwort[2] := 'idiot';  
  passwort[3] := 'weis nicht';  
  passwort[4] := 'x-mas';  
  passwort[5] := 'thematrix';  
  passwort[6] := 'simpsons';  
  passwort[7] := 'welcome';  
  passwort[8] := 'derwixxer';  
  passwort[9] := 'bene';  
  passwort[10] := 'matze';  
  rpw:= passwort[random(10)+1];
end;  

 
procedure TForm1.Button2Click(Sender: TObject);  
var i: Integer;  
begin  
  if Edit1.Text = rpw then  
  Label1.Caption := 'Richtig!';  
end;  

 
end.