Autor Beitrag
Sir.Snyder
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 19

Win 2000
D7 Prof
BeitragVerfasst: Do 24.07.03 11:52 
Hi! Ich habe ein kleines Problem mit einer Case-Anweisung:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
  case combobox1.text  of
    1:  begin
          showmessage('1');
        end;
    2:  begin
          showmessage('2');
        end;
  end;


Ich bekomme ich die Fehlermeldung: Ordinaltyp erforderlich.
Was mache ich verkehrt??? Bin schon total am verzweifeln.

Danke im vorraus
christian

Moderiert von user profile iconKlabautermann: Delphi-Tags hinzugefügt.
Klabautermann
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Veteran
Beiträge: 6366
Erhaltene Danke: 60

Windows 7, Ubuntu
Delphi 7 Prof.
BeitragVerfasst: Do 24.07.03 12:07 
Hallo,

die Fehlermeldung sagt es doch. Du kannst Case nur auf Ordinale (abzählbare) Typen anwenden. Also z.B. auf Integer. Auf String lässt sich Case nciht anwenden dahen kannst du combobox1.text nciht auf diese weise überprüfen.

Gruß
Klabautermann
Bruce
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 80



BeitragVerfasst: Do 24.07.03 12:22 
Waren die Zahlen jetzt nur Platzhalter als Beispiel oder stehen in der Combobox nur Zahlen? Dann könntest Du ja den String aus der Combobox vorher in einen Integer konvertieren in eine Variable schreiben und dann case auf die Variable anwenden.
Gruß, Bruce
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Do 24.07.03 14:02 
Bei einer Combobox bietet sich die Eigenschaft ItemIndex für ein case-statement an..!

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!