Autor Beitrag
maniac_89
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 54



BeitragVerfasst: Sa 25.06.05 09:12 
Hallo,
ich bin dabei in mein Programm eine Serienummer Überprüfung einzubauen, aber das Funktioniert nicht. Hier der Quellcode:

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:
procedure TForm3.Button1Click(Sender: TObject);
var
reg: TStringlist;
zahl1, zahl2, zahl3, zahl4, zahl5, zahl6 : integer;
begin
zahl1 := strtoint (edit1.Text);
zahl2 := strtoint (edit2.Text);
zahl3 := strtoint (edit3.Text);
zahl4 := strtoint (edit4.Text);
zahl5 := strtoint (edit5.Text);
zahl6 := strtoint (edit6.Text);

if (zahl1 < 5) or (zahl1 > 20)  then
  application.MessageBox('Sie haben eine falsche Seriennummer eingegeben. Bitte überprüffen Sie ihre Eingabe.', 'Falsche Seriennummer', 0);
if (zahl2 < 88) or (zahl2 > 99)  then
  application.MessageBox('Sie haben eine falsche Seriennummer eingegeben. Bitte überprüffen Sie ihre Eingabe.', 'Falsche Seriennummer', 0);
if (zahl3 < 56) or (zahl1 > 60)  then
  application.MessageBox('Sie haben eine falsche Seriennummer eingegeben. Bitte überprüffen Sie ihre Eingabe.', 'Falsche Seriennummer', 0);
if (zahl4 < 0) or (zahl4 > 4)  then
  application.MessageBox('Sie haben eine falsche Seriennummer eingegeben. Bitte überprüffen Sie ihre Eingabe.', 'Falsche Seriennummer', 0);
if (zahl5 < 20) or (zahl5 > 30)  then
  application.MessageBox('Sie haben eine falsche Seriennummer eingegeben. Bitte überprüffen Sie ihre Eingabe.', 'Falsche Seriennummer', 0);
if (zahl6 < 5) or (zahl6 > 20)  then
  application.MessageBox('Sie haben eine falsche Seriennummer eingegeben. Bitte überprüffen Sie ihre Eingabe.', 'Falsche Seriennummer', 0)

else
  application.MessageBox('Vielen Dank für ihre Registrierung.', 'Eingabe Erfolgreich', 0);
  reg := TStringlist.Create;
  reg.LoadFromFile(regi);
  reg.Insert(0,edit7.text);
  reg.Insert(1, edit8.Text);
  reg.Insert(2, 'Regist');
  reg.SaveToFile(regi);
  reg.Free;
end;


Das Problem auch wenn die Serienummer falsch ist, schreibt das Programm trotzdem den 'Regist`, Text in die Datei. Ich hoffe ihr könnt mir helfen.


Steffen, Maniac_89

Moderiert von user profile iconGausi: Delphi-Tags hinzugefügt.
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Sa 25.06.05 09:22 
Hallo,

Das Problem ist, dass sich der else-Zweig nur auf die letzte if Bedingung bezieht. D.h. wenn der letzte Teil der Überprüfung ok ist, dann ist alles ok.

Besser (?) gehts so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
if ((zahl1 < 5) or (zahl1 > 20))
    OR ((zahl2 < 88) or (zahl2 > 99))
    OR ((zahl3 < 56) or (zahl1 > 60))
    OR {(...)}
then   
  application.MessageBox('Sie haben eine falsche Seriennummer eingegeben. Bitte überprüffen Sie ihre Eingabe.', 'Falsche Seriennummer', 0)   

else   
  application.MessageBox('Vielen Dank für ihre Registrierung.', 'Eingabe Erfolgreich', 0);
  //...  
end;

_________________
We are, we were and will not be.
maniac_89 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 54



BeitragVerfasst: Sa 25.06.05 09:33 
Hallo,
geht leider immer noch nicht, das Programm schreibt dann immer noch den `Regist`, Text rein, auch wenn die Serienummer falsch ist.

Steffen, Maniac_89
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Sa 25.06.05 09:48 
aaaargh..... :autsch:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
if ((zahl1 < 5) or (zahl1 > 20))   
    OR ((zahl2 < 88) or (zahl2 > 99))   
    OR ((zahl3 < 56) or (zahl1 > 60))   
    OR {(...)}   
then      
  application.MessageBox('Sie haben eine falsche Seriennummer eingegeben. Bitte überprüffen Sie ihre Eingabe.', 'Falsche Seriennummer', 0)      

else
begin
  application.MessageBox('Vielen Dank für ihre Registrierung.', 'Eingabe Erfolgreich', 0); 
  //...     
end;
end;

Ich empfehle uns beiden einen Blick in die Anfänger-Tutorials. :lol:

_________________
We are, we were and will not be.
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Sa 25.06.05 09:49 
Setz mal im True-Teil noch ein Exit hinter den MessageBox-Befehl.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
maniac_89 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 54



BeitragVerfasst: Sa 25.06.05 09:54 
Ok, funktioniert jetzt, vielen Dank für die Hilfe.

Ich bin eben noch in anfänger :lol:
Spaceguide
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 552


(D3/D7/D8) Prof.
BeitragVerfasst: Sa 25.06.05 10:41 
Ich glaub einfacher kann man's den Crackern aber nicht machen.
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Sa 25.06.05 23:49 
@Spaceguide: Jup. Aber das wurde hier ja auch nicht gefragt ... Lassen wir ihn ruhig in dem Glauben, es wäre sicher :P Zum Thema "Wie knackt man das?" haben sich schon genug Threads angesammelt ;-)

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.