Autor Beitrag
Schweini31
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 26



BeitragVerfasst: Mi 23.01.08 21:44 
Hallo, ich weiß, dass case nur mit Ordinaltypen funktioniert, jedoch zeigt mir Delphi trotzdem einen Fehler an.

a,Tausend sind ein Real
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
a:=StrToFloat(edAlgebra.text);
  Tausend:=a/1000;
  Tausend:=Trunc(Tausend);
  a:=a-1000*Tausend;
  case Tausend of
  1: b:='M';
  2: b:='MM';
  3: b:='MMM';
  4: b:='MMMM';
  end;


Fehler: Ordinaltyp erforderlich

Mit Trunc wandle ich doch einen Real in einen Integer um.

Ich versteh nicht was ich flasch gemacht habe :(
Könnt ihr mir bitte sagen was ich falsch gemacht habe?

Schweini
nagel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 708

Win7, Ubuntu 10.10

BeitragVerfasst: Mi 23.01.08 21:50 
Tausend ist immer noch eine Real-Variable, auch wenn du die Nachkommastellen abschneidest.
Yogu
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2598
Erhaltene Danke: 156

Ubuntu 13.04, Win 7
C# (VS 2013)
BeitragVerfasst: Mi 23.01.08 21:50 
user profile iconSchweini31 hat folgendes geschrieben:
a,Tausend sind ein Real

Eben. Die sind und bleiben ein Real. Wie sollte sich denn der Variablentyp durch Zuweisen eines neuen Werts ändern? Du musst eine neue Integer-Variable deklarieren, die dann die Funktion von Tausend annimmt.
Schweini31 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 26



BeitragVerfasst: Mi 23.01.08 22:07 
Ok vielen Dank!
Funktioniert