Autor Beitrag
daggit
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 56



BeitragVerfasst: So 22.10.06 15:37 
Hi,

ich möchte gerne den Inhalt einer Variablen per Formulareingabe setzen. Nun soll diese Variable entweder numerischen Inhalt besitzen, oder garnix. Ich denke mal das man in diesem Fall der Variablen NAN zuweisen müsste oder etwas vergleichbares.

Hat jemand spontan einen göttlichen Rat parrat? :)
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: So 22.10.06 15:41 
Ich glaube nicht das Jesus, Jahwe, Allah usw. Mitglieder dieses Forums sind. :mrgreen:
Du mußt halt vorher durch varStrTo<Type> abtesten, ob die Eingabe in Ordnung ist.

_________________
Markus Kinzler.
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: So 22.10.06 16:02 
Numerischer Typ? Du meinst eine Zahl? Wenn du Double verwendest, kannst du ja NaN zuweisen. Also wenn der Inhalt gültig ist: Zahl, wenn ungültig: NaN;

AXMD
Reinhard Kern
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 591
Erhaltene Danke: 14



BeitragVerfasst: So 22.10.06 17:34 
user profile icondaggit hat folgendes geschrieben:
Hi,

ich möchte gerne den Inhalt einer Variablen per Formulareingabe setzen. Nun soll diese Variable entweder numerischen Inhalt besitzen, oder garnix. Ich denke mal das man in diesem Fall der Variablen NAN zuweisen müsste oder etwas vergleichbares.

Hat jemand spontan einen göttlichen Rat parrat? :)


Hallo,

so etwas wie NAN gibt es nur für Gleitkomma-Zahlen. Für eine allgemeine Lösung must du wohl einen Record oder ein Objekt benutzen mit zusätzlichem Feld "gültig".

Ein Byte z.B. kann die Werte 0..255 annehmen, alle sind gültig, und was anderes kann man nicht speichern.

Gruss Reinhard