Autor Beitrag
GrimReaper
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 21



BeitragVerfasst: Mo 05.06.06 18:42 
sorry wieder ne blöde frage von mir aber ich komm da echt nicht weiter ^^'

also ich würde mal gern die case Funktion anwenden weiß aber nicht wie der komplette Aufbau aussieht


Aus einem Crashkurs über Delphi hab ich das:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
case zahl of
  0: anweisung1;
  1: anweisung2;
  2: anweisung3;
  3: anweisung4;
  4: anweisung5;
  5: anweisung6;
end;

aber egal wie ich es versuche, bekomme ich es nicht zum laufen zu bekommen...
was genau fehlt den da, was muss bei var hin und was muss unter beginn ...


könnte einer die Funktion vollenden, ich würde mir gern den Aufbau anschauen, damit ich's endlich kapiere

Moderiert von user profile iconChristian S.: Delphi-Tags hinzugefügt
Moderiert von user profile iconChristian S.: Topic aus Sonstiges (Delphi) verschoben am Mo 05.06.2006 um 18:49
DelphiAnfänger
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 112

Win XP, Firefox 2.0, IE6
Delphi 5 Prof., Delphi 2005 PE
BeitragVerfasst: Mo 05.06.06 18:44 
eigentlich ist das so vollkommen korrekt poste mal mehr quelltext ich denke der fehler ligt wonders
PS es gibt den [delphi][/delphi] tag
GrimReaper Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 21



BeitragVerfasst: Mo 05.06.06 18:55 
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:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
  var zahl : integer;
      anweisung1, anweisung2 : string;
begin
case zahl of
  0: anweisung1;
  1: anweisung2;
end;
end;

end.


Moderiert von user profile iconChristian S.: Delphi-Tags hinzugefügt
DelphiAnfänger
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 112

Win XP, Firefox 2.0, IE6
Delphi 5 Prof., Delphi 2005 PE
BeitragVerfasst: Mo 05.06.06 19:02 
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:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Edit1: TEdit;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var zahl : integer;
 anweisung1, anweisung2 : string;
begin
zahl:=0
anweisung1:='hallo';
anweisung2:='Welt';

case zahl of
  0Edit1.text:=anweisung1;
  1Edit1.text:=anweisung2;
end;
end;

end.
GrimReaper Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 21



BeitragVerfasst: Mo 05.06.06 19:08 
bei mir zeigt er so aber immer nur Hallo an
was müsste man dann noch machen damit auch mal Welt angezeigt wird?
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Mo 05.06.06 19:13 
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:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    procedure Button1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;
  Zahl:Integer;
  anweisung : string;
implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  case zahl of
    0: anweisung:='Hallo';
    1: anweisung:='Welt';
  end;
  Inc(Zahl);
  Edit1.Text:=anweisung;
end;


end.


Zuletzt bearbeitet von Blackheart666 am Mo 05.06.06 19:28, insgesamt 1-mal bearbeitet
GrimReaper Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 21



BeitragVerfasst: Mo 05.06.06 19:25 
danke jetzt geht's ^^

hätte aber noch fragen dazu
warum musste man zahl und anweisung global deklarieren (hatte ja der nicht gemacht)

und hätte man anstatt dem Inc(Zahl); etwas anderes machen können, habe so was bei uns im Unterricht nicht gesehen