Autor Beitrag
Smartie
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 205



BeitragVerfasst: Mi 27.04.05 15:07 
Servus!

Also, ich denke eigentlich beim Programieren ein bischen mathematishc, bringt mich an sich weiter. Und so komtm auch meine Frage: Gibt es in Delphi etwas wie "nicht Element von"?

sprich, "if a §nicht element von§ Integer then"

Lieben Gruß

Smartie
AXMD
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 4006
Erhaltene Danke: 7

Windows 10 64 bit
C# (Visual Studio 2019 Express)
BeitragVerfasst: Mi 27.04.05 15:13 
Ja, aber nicht sowas, was du suchst. Mengen gehen nur, wenn sie von ordinalen Typen (abzählbar) sind - und da gibts nichts größeres als Integer. Sonst mach doch:

ausblenden Delphi-Quelltext
1:
if Round(a * 1E10) <> Trunc(a * 1E10) then					


AXMD
Smartie Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 205



BeitragVerfasst: Mi 27.04.05 15:16 
Naja, es geht darum, daß ich DAU-eingaben abfangen möchte, im Sinn von "Geben sie hiereine Zahl von 1 bis 30 eu" und jemand schreibt Hallo

Ich weiß, sowas kann ich über die try-exception abfangen (muß mir das halt noch genauer ansehn) aber es fiel mir als lösung ein, deswegen meine frage.

Lieben Gruß

Smartie
csigg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 706

WIn XP, Win NT, Win2000, Suse8.0
Delphi 5, Delphi 6
BeitragVerfasst: Mi 27.04.05 15:20 
Versuchs doch mal mit Maskedit, falls da etwas für dich dabei ist, wär glaub die einfachste Lösung.
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Mi 27.04.05 15:25 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
var
 i: Integer;
begin
 i := 45;
 if not (i in [1..30]) then // "i ist nicht Element von [1..30]"
  // ...
end;
Aber i muss hier natürlich schon eine Zahl (Integer) beinhalten. Das eigentliche Problem taucht ja bei der Konversion auf. Dort kommst du nicht drum herum, einfach mal eine Konversion durchzuführen, und beim Fehlerfall eine entsprechende Meldung anzuzeigen.
Smartie Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 205



BeitragVerfasst: Mi 27.04.05 15:28 
Alles klar, dankeschön.

Das Problem mit kleiner Null und Größer (Variable Zahl), hab ich schon gelöst. wär halt noch gewesen, wenn es keine Zahl ist.

Lieben Gruß

Smartie