Autor Beitrag
julian2003
Hält's aus hier
Beiträge: 7



BeitragVerfasst: Fr 11.01.08 18:34 
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
var
  Form_Start: TForm_Start;
  current_number,amount: integer;
   operation: char;
implementation

{$R *.DFM}

procedure TForm_Start.Button1Click(Sender: TObject);
begin
edit_eingabe.text:='0';
label1_ergebnis.caption:='';
amount:=0;
end;

procedure TForm_Start.Button_plusClick(Sender: TObject);
begin
current_number:= strtoint(edit_eingabe.Text);
amount := amount + current_number;

operation:= '+';
end;

procedure TForm_Start.Button_istClick(Sender: TObject);
begin
case
 operation of
  '+':  current_number:= strtoint(edit_eingabe.Text);
        amount:= amount + current_number;
        label1_ergebnis.caption := inttostr(amount);
        edit_eingabe.Text:= inttostr(0);
   '-': current_number:= strtoint(edit_eingabe.Text);
        amount:= amount - current_number;
        label1_ergebnis.caption := inttostr(amount);
        edit_eingabe.Text:= inttostr(0);
   '*': current_number:= strtoint(edit_eingabe.Text);
        amount:= amount * current_number;
        label1_ergebnis.caption := inttostr(amount);
        edit_eingabe.Text:= inttostr(0);
   '/': current_number:= strtoint(edit_eingabe.Text);
        amount:= amount div current_number;
        label1_ergebnis.caption := inttostr(amount);
        edit_eingabe.Text:= inttostr(0);
end;

end;

procedure TForm_Start.Button_minusClick(Sender: TObject);
begin
current_number:= strtoint(edit_eingabe.Text);
amount := amount - current_number;

operation:= '-';
end;

procedure TForm_Start.Button_malClick(Sender: TObject);
begin
current_number:= strtoint(edit_eingabe.Text);
amount := amount * current_number;

operation:= '*';
end;

procedure TForm_Start.Button_durchClick(Sender: TObject);
begin
current_number:= strtoint(edit_eingabe.Text);
amount := amount div current_number;

operation:= '/';
end;

end.


BEI case operation of kommt die fehlermeldung bei allen vier amount-zeilen "konstantenausdruck erwartet". was stimmt hier nicht?

danke, mfg, julian

Moderiert von user profile iconNarses: Delphi-Tags hinzugefügt und bold durch highlight ersetzt
Moderiert von user profile iconChristian S.: Topic aus Sonstiges (Delphi) verschoben am Fr 11.01.2008 um 18:42
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Fr 11.01.08 18:41 
Hallo!

Auch bei einer case-Anweisung musst Du, wenn mehrere Anweisungen ausgeführt werden sollen, diese in einen begin-end-Block verpacken.

Grüße
Christian

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".