Autor Beitrag
SebastianWe
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 44

Win XP Pro
Delphi 7
BeitragVerfasst: So 23.05.04 10:50 
So,
hab noch mal ne kleine Frage, wie kann ich eine CheckBox.Checked Wert überprüfen? Ich habe es so probiert:
ausblenden Delphi-Quelltext
1:
2:
if (CheckBox1.Checked = 'true') then
end;

Aber als Fehler bekomme ich : 'Inkompatible Typen String und Bolean.

Wie kann ich das umschreiben?

Danke

Moderiert von user profile iconPeter Lustig (12:02, 23.05.2004): Code- durch Delphi-Tags ersetzt
FaTaLGuiLLoTiNe
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 200
Erhaltene Danke: 5

Windows 7, Windows 8.1
Delphi XE
BeitragVerfasst: So 23.05.04 10:54 
ausblenden Delphi-Quelltext
1:
2:
3:
if CheckBox1.Checked then
 begin
 end;


Der entgegengesetzte Fall wäre dann

ausblenden Delphi-Quelltext
1:
2:
3:
if not CheckBox1.Checked then
 begin
 end;

_________________
<< FaTaLGuiLLoTiNe >>
Rhinoceroses don't play games!
raziel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2453

Arch Linux
JS (WebStorm), C#, C++/CLI, C++ (VS2013)
BeitragVerfasst: So 23.05.04 10:54 
so:
ausblenden Delphi-Quelltext
1:
if CheckBox1.Checked then					


raziel

_________________
JSXGraph
Raphael O.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1596


VS 2013
BeitragVerfasst: So 23.05.04 10:55 
einfach beim true die Hochkommas weglassen, da du so einen boolean mit einem string (die ZEichenkette "true") vergleichst, was nicht klappen kann...

du könntest alternativ übrigens auch das "= true" weglassen, da der Ausdruck checkbox1.checked schon selber entweder true oder false ist... musst du aber nciht ;)

die Klammern sind übrigens auch nicht nötig, wie es in anderen Sprachen häufig der Fall ist...

dann das "end;" kannst du nur schreiben, wenn du vorher ein "begin" gesetzt hast, da die if ... then Struktur ein solches nicht direkt darstellt...

du kannst allerdings das begin ... end auch weglassen, dann wird einfach die nächste Codeoperation nur unter der Bedingung des if .. then s ausgeführt und der REst normal...
wenn es mehrere Kommandos sind, dann brauchst du ein begin und am ende ein end;
FaTaLGuiLLoTiNe
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 200
Erhaltene Danke: 5

Windows 7, Windows 8.1
Delphi XE
BeitragVerfasst: So 23.05.04 10:56 
Hehe jetzt sollte er es aber verstanden haben :D

_________________
<< FaTaLGuiLLoTiNe >>
Rhinoceroses don't play games!
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: So 23.05.04 11:04 
Hallo!

Du musst Deine Fragen übrigens nicht mit "Delphi Frage" kennzeichnen. In den Programmiersparten werden ausschließlich Fragen zu Delphi gestellt. :-)

MfG
Peter

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


D7
BeitragVerfasst: So 23.05.04 11:38 
Falls TCheckBox.AllowGrayed=true ist, so kann es auch einen dritten Zustand geben (siehe Hilfe). Dann wird auch TCheckBox.State interessant.