Autor Beitrag
Andreas L.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1703
Erhaltene Danke: 25

Windows Vista / Windows 10
Delphi 2009 Pro (JVCL, DragDrop, rmKlever, ICS, EmbeddedWB, DEC, Indy)
BeitragVerfasst: Sa 25.01.03 12:42 
Hi,
ich möchte meinen eigenen Serial für ein Programm bauen. Hab mir das so vorgestellt das der Serial in ein Edit bzw. Memo eingetragen wird, das Eingegebene wird mit den Vorgegebenen nichtsichtbaren verglichen, wenn der Serial richtig ist soll Button1 und Picture1 enabled werden! Der Serial soll bis zu 5 Zeichen lang sein, kann aber auch mehr oder weniger sein!

Ich glaube das geht irgendwie so:
ausblenden Quelltext
1:
2:
3:
4:
procedure...
begin
  if memo1.text := ('12345') then button1.enabled :=TRUE;
end;

Ich bekomme aber die Fehlermeldung: Ausdruckstyp muss Boolean sein!

Bitte komplette proceduren!

Schon mal Danke

Moderiert von user profile iconTino: Code-Tags hinzugefügt.
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Sa 25.01.03 12:54 
du könntest ja aus ner zahlenkette die quersumme bilden und schaun on die quersumme richtig ist also die geliche sit wie du willst.

das ist zwar nicht wirklich sicher aber für erste reichts !!!

_________________
In the beginning was the word.
And the word was content-type: text/plain.
Andreas L. Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1703
Erhaltene Danke: 25

Windows Vista / Windows 10
Delphi 2009 Pro (JVCL, DragDrop, rmKlever, ICS, EmbeddedWB, DEC, Indy)
BeitragVerfasst: Sa 25.01.03 13:18 
Und wie stell ich das an?
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Sa 25.01.03 13:48 
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
Function Quersumme(i : integer): integer;
var p: pchar;
begin
 result := 0;
 p := Pchar(IntToStr(i));
 while (p^ <> #0) do
 begin
   result := result + strtoint(p^);
   Inc(p);
 end;
end;

_________________
In the beginning was the word.
And the word was content-type: text/plain.
Andreas L. Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1703
Erhaltene Danke: 25

Windows Vista / Windows 10
Delphi 2009 Pro (JVCL, DragDrop, rmKlever, ICS, EmbeddedWB, DEC, Indy)
BeitragVerfasst: Sa 25.01.03 14:32 
Danke @matze.

Ich möchte doch lieber so wie oben machen, kann mir jemand tipps oder proceduren geben!
GSE
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 740

Win 2k, Win XP Pro
D5 Prof, D6 Ent, D2k5 PE
BeitragVerfasst: Sa 25.01.03 14:46 
@onlinehome

ausblenden Quelltext
1:
if memo1.text := ('12345') then button1.enabled :=TRUE;					


Du bekommst hier den Fehler, da bei Vergleichen in Pascal
das Gleichheitszeichen verwendet wird (=) :idea:

Also:
ausblenden Quelltext
1:
if memo1.text = ('12345') then button1.enabled :=TRUE;					


mfg
GSE

_________________
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs
and the universe trying to produce bigger and better idiots. So far, the universe is winning. (Richard Cook)
Andreas L. Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1703
Erhaltene Danke: 25

Windows Vista / Windows 10
Delphi 2009 Pro (JVCL, DragDrop, rmKlever, ICS, EmbeddedWB, DEC, Indy)
BeitragVerfasst: Sa 25.01.03 14:51 
Danke @GSE, dir auch matze!

Jetzt funktioniert alles!
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Sa 25.01.03 14:57 
oh mann.... das kommt davon, wenn man die frage nicht ganz bis zum schluss durchliest !!!
sonst hätte ich dir das if memo1.text = ('12345') then button1.enabled :=TRUE; gleich gesagt !!! :autsch:

_________________
In the beginning was the word.
And the word was content-type: text/plain.
Brueggendiek
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 304

Win 98, Win98SE, Win XP Home
D5 Std
BeitragVerfasst: Sa 25.01.03 15:03 
Hallo!

Da geht ja einiges durcheinander!

onlinehome hat folgendes geschrieben:
ausblenden Quelltext
1:
if memo1.text := ('12345') then button1.enabled :=TRUE;					

Wenn Du das SO geschrieben hast, ist es kein Wunder, daß Delphi meckert - da ist ein ":" zuviel und die Klammern sind auch zumindest überflüssig! Nach Deiner Fehlermeldung zu urteilen wird das mit dem ":" wohl so sein! Richtig ist:
ausblenden Quelltext
1:
2:
if memo1.text = '12345' then
  button1.enabled :=TRUE;


Allerdings muß der Wert mit False initialisiert sein (z.B. im OI). Wenn nur die eine Frage den Button steuert, geht es auch ganz einfach:
ausblenden Quelltext
1:
button1.enabled := memo1.text = '12345';					

dann wir der Button sicher disabled, wenn der Wert nicht stimmt.


@matze: warum verwendest Du denn einen pChar? Mit String geht das doch viel einfacher!

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
Function Quersumme(i : integer): integer; 
var s: string; 
  p: Integer;
begin 
result := 0; 
s := IntToStr(i); 
for p:=1 to Length(s) do
   result := result + StrToInt(s[p]); 
end;


aber warum auch einfach, wenn es doch kompliziert geht :mrgreen:

Gruß

Dietmar Brüggendiek

PS: Mist - zu spät!
Andreas L. Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1703
Erhaltene Danke: 25

Windows Vista / Windows 10
Delphi 2009 Pro (JVCL, DragDrop, rmKlever, ICS, EmbeddedWB, DEC, Indy)
BeitragVerfasst: Sa 25.01.03 15:24 
Immer ruhig bleiben :lol:

Benutze zum Programmieren auch nur dieses Forum, hab kein einziges Buch über Delphi. Also stell ich halt ab und zu mal ne leichte Frage! OK :shock: :D :lol: 8) :P

@Matze: Macht nichts :autsch: