Autor Beitrag
del1312
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 190



BeitragVerfasst: Sa 15.04.06 00:09 
ich habe zwei string werte a und b und möchte eine if schleife bauen. nur klappt das nicht.

Zitat:
if wert1='' AND wert2='' then showmessage('Es wurden keine Werte eingegeben!');


hat einer nee idee ich man das macht?
Allesquarks
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 510

Win XP Prof
Delphi 7 E
BeitragVerfasst: Sa 15.04.06 00:33 
"and Wert2" denk doch mal nach. Was soll denn das heißen und wert zwei? Was und mit was und and braucht zwei operanden. Es wird aber auch gar nicht klar was du tun möchtest, denn selbst wenn du einen zweiten Operanden angegeben hättest, wie soll denn der Computer einen STring auf gleichheit mit einem Wahrheitswert überprüfen??
Ironwulf
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 733
Erhaltene Danke: 2



BeitragVerfasst: Sa 15.04.06 00:44 
bei mir klappts wenn man das noch fein einklammert
ausblenden Delphi-Quelltext
1:
if (wert1='') And (wert2='') Then showmessage('')					
bs-Hobbit
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 46

Windows Xp (Home/Prof.), Windows Server 2003, Linux
D7,D2005
BeitragVerfasst: Sa 15.04.06 00:44 
Ich weiss ja nicht genau was eine "If Schleife" ist, aber naja ...

vielleicht hilft dir das hier weiter
ausblenden Delphi-Quelltext
1:
2:
if (wert1='') AND (wert2='') then 
  showmessage('Es wurden keine Werte eingegeben!');
MrSaint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1033
Erhaltene Danke: 1

WinXP Pro SP2
Delphi 6 Prof.
BeitragVerfasst: Sa 15.04.06 10:12 
Das Problem ist, dass and stärker bindet als das =. Sprich: es wird zuerst das "'' and Wert2" ausgewertet, nicht das "Wert1 = ''". Das ist wie "Punkt vor Strich". Deshalb muss man hier die Klammern setzen.


MrSaint

_________________
"people knew how to write small, efficient programs [...], a skill that has subsequently been lost"
Andrew S. Tanenbaum - Modern Operating Systems