![]() |
3 verschiedene Zustände ?
hallo,
habe da eine art ampel mit drei shape's, shape1 = rot, shape2 = gelb, shape3 = grün jetzt frage ich einen wert in einen editfeld ab mit diesen wert zb. 90 möchte ich jetzt die ampel schalten, aber ich bringe nur 2 zustände zusammen !!! wie bringe ich 3 zustände zusammen ?
Delphi-Quellcode:
var a: real;
begin a := strtofloat (edit1.Text); if a<90 then shape1.Visible:=true else shape2.Visible:=true ; end; mfg vader |
Re: 3 verschiedene Zustände ?
Hi!
Case ist hier wohl sinnvoll, wenn ich dich richtig verstehe. Ciao Frederic |
Re: 3 verschiedene Zustände ?
Wie wäre es damit :wink: ?
Delphi-Quellcode:
[edit] @fkerber: Wie würdest du das mit case schreiben?
a := StrToFloat(Edit1.Text);
if (a > 0) and (a < 34) then Shape1.Visible := true; if a > ... then Shape2.Visible := true; if a > ... then Shape3.Visible := true; |
Re: 3 verschiedene Zustände ?
Und warum ist a vom Typ Real. Integer scheint es doch auch zu tun.
Delphi-Quellcode:
var
a: Integer; begin case a of 0..89:; 90..169:; 260..349:; ...; end; |
Re: 3 verschiedene Zustände ?
Zitat:
Delphi-Quellcode:
[edit] Jetzt war der Michael schon wieder schneller :grummel: [/edit]
case Integer of
0..142: machdas; 143..938: machdies; 939..1342: machjenes; end; |
Re: 3 verschiedene Zustände ?
Und mit einem nicht ordinalen Typ :P ?
Okay, kann natürlich sein, dass es in diesem Fall Integer auch tut. |
Re: 3 verschiedene Zustände ?
klappt sowieso alles nicht, was ihr hier vorschlagt. Irgendwann sind alle drei shapes sichtbar. Entweder vor dem Case alle Shapes erstmal unsichtbar machen, oder gleich so::
Delphi-Quellcode:
Fur e = 0..49 ist S1 an, S2 (wg Not S1) Aus und S3 auch (wg. S1 = True)
Shape1.Visible := (e < 50);
Shape2.Visible := not Shape1.Visible and (e < 70); Shape3.Visible := not (Shape2.Visible or Shape3.Visible); Fur e = 50..69 ist S1 aus, dafür S2 an und S3 nicht. Sonst ist S1 aus, S2 auch, aber nun ist S3 an. (Hoffentlich ist das jetzt hier richtig, sonst mach ich mich noch zum Horst) |
Re: 3 verschiedene Zustände ?
hallo,
danke für eure tipps, der erste hat schon funktioniert ! mfg vader |
Alle Zeitangaben in WEZ +1. Es ist jetzt 02:30 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz