Autor Beitrag
chriss1988
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 389

windows xp prof,home,windows98
delphi5
BeitragVerfasst: Mi 08.02.06 09:48 
hi
ich schreibe ein programm bei dem man zur aktivierung einen pin eingeben muss
ist der pin falsch kommt eine fehlermeldung wie z.B pin falsch.
also ich hab 3 verschiedene pins bei pin 1 und 3 funktioniert alles wunderbar nur beim 2 pin harbert es ich geb den pin richtig an er startet das programm wie er es sollte nur will ich jetzt auf die startseite zurück indem ich form 2 und 3 schließe bringt er mir bei schließen der formen die fehlermeldung
pincode falsch.
dann drück ich auf ok und dann erst schließt er das programm.

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:
procedure TForm2.Button1Click(Sender: TObject);
begin
code1:=1122;
code2:=5788;
code3:=1010;
pin:=strtofloat(edit1.text);

if pin=code1 then
 form3.Panel1.caption:='2000';
if pin=code1 then
form3.showmodal

else

if pin=code2 then
 form3.Panel1.caption:='4500';
if pin=code2 then
form3.showmodal

else

if pin=code3 then
 form3.Panel1.caption:='1337';
if pin=code3 then
form3.showmodal
else

if pin<>code1 then    //fehler bitte koregiern
showmessage('!ACHTUNG!  Pin code Falsch');
 edit1.clear;
  edit1.setfocus

end;
inselberg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 458



BeitragVerfasst: Mi 08.02.06 09:52 
streu mal wild en paar begin end; hinter deine thens .. ich hab so im gefühl dass das helfen wird ;)

_________________
hans bist du das ?
chriss1988 Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 389

windows xp prof,home,windows98
delphi5
BeitragVerfasst: Mi 08.02.06 09:56 
meinst du hinter alle oder nur hinter die bei der fehler meldung
inselberg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 458



BeitragVerfasst: Mi 08.02.06 10:24 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
if pin=code2 then   
 form3.Panel1.caption:='4500';   
if pin=code2 then
 form3.showmodal

wieso machst du nicht
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
if pin=code2 then   
begin
 form3.Panel1.caption:='4500';   
 form3.showmodal
end

ist logischer, schöner und ganz wichtig man kanns dann auch lesen
oder en "case pin"

könnte sogar den nebeneffekt haben dass es dann läuft

Moderiert von user profile iconraziel: Code- durch Delphi-Tags ersetzt

_________________
hans bist du das ?
chriss1988 Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 389

windows xp prof,home,windows98
delphi5
BeitragVerfasst: Mi 08.02.06 12:41 
wie case pin ???
Tobias1
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 454

Win 98, XP Prof
D3 Prof, D2005 Prof
BeitragVerfasst: Mi 08.02.06 12:50 
Wenn pin vom typ Integer ist (ganzzahlig)
kannst du das so schreiben
ausblenden Delphi-Quelltext
1:
2:
3:
4:
case pin of
1337:begin Anweisungen end;
5000:begin Anweisungen end;
end;

_________________
Auch das schlechteste Buch hat seine gute Seite: die letzte. (John Osborne)
Tobias1
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 454

Win 98, XP Prof
D3 Prof, D2005 Prof
BeitragVerfasst: Mi 08.02.06 12:59 
Das ganze könntest du auch viel kürzer schreiben; du kannst nämlich Abfragen zwischen if - then verknüpfen z.B mit or andusw.

z.B so

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
if (pin=code1) or (pin=code3) or (pin=code3) then
begin
 form3.showmodal;
 form3.Panel1.caption:=floattostr(pin);
end
else  // wird Ausglöst wenn if-Anweisung false zurückgibt
begin
 showmessage('!ACHTUNG!  Pin code Falsch');
 edit1.clear;
 edit1.setfocus
end;


vielleicht hilft dir auch das:
:arrow: dsdt.info/grundlagen...he/verzweigungen.php

_________________
Auch das schlechteste Buch hat seine gute Seite: die letzte. (John Osborne)
chriss1988 Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 389

windows xp prof,home,windows98
delphi5
BeitragVerfasst: Mi 15.02.06 11:11 
danke aber ich habs auch anders behoben