Autor Beitrag
kkkiwi
Hält's aus hier
Beiträge: 6



BeitragVerfasst: Di 21.06.05 18:09 
hallo ihr

eigentlcih sollte ich dieses programm zuhause fertig machen, aber leider funktioniert nun gar nichts mehr.

wäre nett wenn mir jemand helfen könnte

eigentlich sollte in der stringrid die daten der aus der radiogroup ausgewählten fahrzeuge eigetragen werden
wer nett wenn mir jemand helfen könnte

also hier ist das programm

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:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    RadioGroup1: TRadioGroup;
    Button1: TButton;
    Button2: TButton;
    Edit1: TEdit;
    Edit2: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    StringGrid1: TStringGrid;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

  Type Kfzart = (PKW, LKW, Motorrad);
Fahrzeugtyp = record
Baujahr:integer;
case KFZ: KFZart of
PKW: (Sitze:Byte);
LKW: (Achsen,Nutzlast: Integer);
Motorrad:(Seitenwagen: Boolean);


end;
var

KFZFELD: array[1..5of fahrzeugtyp;
LAufvar:Byte;
Wahl:Char;



implementation


uses unit2, Unit1;

{$R *.dfm}

procedure TForm1.FormCreate(Sender: TObject);
begin
Laufvar:=0;
end;





procedure TForm1.Button1Click(Sender: TObject);
begin

Laufvar:=laufvar+1;
Edit2.text:= inttostr(laufvar);
if Laufvar <= 5 then
begin
KFZFeld[Laufvar].Baujahr:=strtoint(edit1.text);

case Fahrzeugauswahl.ItemIndex of

0begin
KFZFeld[Laufvar].KFZ:=PKW;
form2.label1.caption:='Anzahl der Sitze';
// KFZfelf[laufvar].sitze:=strtoint]
form2.edit2.text:='******************************';
form2.edit2.readonly:=true;
form2.showmodal;
form2.label3.caption:='';
form2.label4.caption:='';
end{PKW}

1begin
KFZFeld[Laufvar].KFZ:=LKW;
form2.show;
form2.label1.caption:='Achsen';
form2.label2.caption:='Nutzlast';
form2.edit2.text:='';
form2.edit2.readonly:=false;
form2.label3.caption:='';
form2.label4.caption:='Tonnen';
end{LKW}

2begin
KFZFeld[Laufvar].KFZ:=Motorrad;
form2.show;
form2.label1.caption:='Seitenwagen';
form2.label2.caption:='';
form2.edit2.text:='******************************';
form2.edit2.readonly:=true;
form2.label4.caption:='';
form2.label3.caption:='';
end;

end;
end{MOTOrrad}
end;//CASE



  procedure TForm1.Button2Click(Sender: TObject);

var i: integer;
begin

Form1.stringgrid1.cells [0,0]:= 'Fahrzeuge';
Form1.stringgrid1.cells[0,1]:='PKW';
Form1.stringgrid1.cells[0,2]:='LKW';
Form1.stringgrid1.cells[0,3]:='Motorrad';
Form1.stringgrid1.cells[1,0]:='Baujahr';
Form1.stringgrid1.cells[2,0]:='Sitze';
Form1.stringgrid1.cells[3,0]:= 'Seitenwagen';
Form1.stringgrid1.cells[4,0]:= 'Achsen';
Form1.stringgrid1.cells[5,0]:= 'Nutzlast';

for i:=1 to 5 do
case KFZFeld[i].KFZ of Pkw:
begin
Form1.stringgrid1.cells [1,1]:=inttostr(KFZFeld[].Baujahr);
Form1.stringgrid1.cells[2,1]:=inttostr(KFZFeld[i].Baujahr);
end;
Lkw:
begin
Form1.stringgrid1.cells [1,2]:=inttostr(KFZFeld[2].Baujahr);
Form1.stringgrid1.cells [5,2]:=inttostr(KFZFeld[4].nutzlast);
Form1.stringgrid1.cells [4,2]:=inttostr(KFZFeld[4].Achsten)
end;
Motorrad
begin
Form1.stringgrid1.cells [1,3]:=inttostr(KFZFeld[5].Baujahr);
Form1.stringgrid1.cells [3,3]:=inttostr(KFZFeld[5].Seitenwagen
end;

end.


und:

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:
unit Unit2;

interface

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

type
  TForm2 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    Edit2: TEdit;
    Label1: TLabel;
    Label2: TLabel;
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form2: TForm2;

implementation

uses Unit1;

{$R *.dfm}

if modalresult= mrok
then begin
if form1.Fahrzeugauswahl.itemindex=0 then
begin
KFZFeld[laufvar].sitze:=strtoint(edit1.text);
form2.hide;
end
else
begin

KFZFeld[laufvar].Achsen:=strtoint(edit1.text);
KFZFeld[laufvar].Nutzlast:=strtoint(edit1.text);
form2.hide;
end;
end;
end;
end.
 


end.


Moderiert von user profile iconAXMD: Delphi-Tags hinzugefügt.


Zuletzt bearbeitet von kkkiwi am Di 21.06.05 18:38, insgesamt 1-mal bearbeitet
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: Di 21.06.05 18:13 
1.) Bitte eine etwas genauere Spezifikation von "funktioniert nicht"

2.) Formatier deinen Quelltext bitte ordentlich - so wird ihn niemand lesen ;)

AXMD
kkkiwi Threadstarter
Hält's aus hier
Beiträge: 6



BeitragVerfasst: Di 21.06.05 18:20 
also
wenn ich das programm starte dann bekomm ich in unit 2 immer die fehlermeldung:

ausblenden Delphi-Quelltext
1:
     if modalresult= mrok					

[Fehler] Unit2.pas(31): Deklaration erwartet, aber 'IF' gefunden
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: Di 21.06.05 18:24 
Hi :)!

Bitte ändere deinen Titel deines Beitrags so, dass er den Richtlinien entspricht. Dazu einfach den EDIT-Button rechts oben verwenden.

Richtlinien hat folgendes geschrieben:
1.2 Beiträge
Bitte formuliere den Betreff Deiner Beiträge so, dass andere Mitglieder anhand dieser bereits das eigentliche Thema festmachen können. Beiträge wie etwa "Eine Anfängerfrage" oder "Weiß jemand, wie das geht?" lassen den Leser im Unklaren darüber, was das Thema der Diskussion ist. [..]


Danke :)
AXMD

PS. Woher soll das Modalresult da außerhalb jedes Events kommen?
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Di 21.06.05 18:34 
Ich habe mal deinen Source ein wenig überarbeitet, damit man das lesen kann.
Meine Änderungen müssen nicht richtig sein, da ich nicht weiß, ob du die Prüfung im FormClose überhaupt machen willst. Eventuell willst du das bei einem Button machen?
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:
unit Unit2;

interface

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

type
  TForm2 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    Edit2: TEdit;
    Label1: TLabel;
    Label2: TLabel;
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form2: TForm2;

implementation

uses Unit1;

{$R *.dfm}

// Folgendes (oder ähnliches):
procedure TForm2.FormClose(Sender: TObject);
begin
// hat gefehlt
  if modalresult= mrok then begin
    if form1.Fahrzeugauswahl.itemindex=0 then begin
      KFZFeld[laufvar].sitze:=strtoint(edit1.text);
      form2.hide;
    end
    else
    begin
      KFZFeld[laufvar].Achsen:=strtoint(edit1.text);
      KFZFeld[laufvar].Nutzlast:=strtoint(edit1.text);
      form2.hide;
    end;
  end;
end;

end.
 


end.
kkkiwi Threadstarter
Hält's aus hier
Beiträge: 6



BeitragVerfasst: Di 21.06.05 18:56 
hallo
also erst mal danke
die unit2 funktioniert erst mal ;)
hab auch noch n paar fehler in unit1 gefunden.. aber meine Tabelle funktioniert immer noch nicht so ganz...


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:
 procedure TForm1.Button2Click(Sender: TObject);

var i: integer;
begin

Form1.stringgrid1.cells [0,0]:= 'Fahrzeuge';
Form1.stringgrid1.cells[0,1]:='PKW';
Form1.stringgrid1.cells[0,2]:='LKW';
Form1.stringgrid1.cells[0,3]:='Motorrad';
Form1.stringgrid1.cells[1,0]:='Baujahr';
Form1.stringgrid1.cells[2,0]:='Sitze';
Form1.stringgrid1.cells[3,0]:= 'Seitenwagen';
Form1.stringgrid1.cells[4,0]:= 'Achsen';
Form1.stringgrid1.cells[5,0]:= 'Nutzlast';

for i:=1 to 5 do
case KFZFeld[i].KFZ of Pkw:
begin
Form1.stringgrid1.cells [1,1]:=inttostr(KFZFeld[2].Baujahr); 
Form1.stringgrid1.cells[2,1]:=inttostr(KFZFeld[2].Baujahr);
end;
Lkw:
begin
Form1.stringgrid1.cells [1,2]:=inttostr(KFZFeld[2].Baujahr);
Form1.stringgrid1.cells [5,2]:=inttostr(KFZFeld[4].nutzlast);
Form1.stringgrid1.cells [4,2]:=inttostr(KFZFeld[4].Achsen)
end;
Motorrad:
begin
Form1.stringgrid1.cells [1,3]:=inttostr(KFZFeld[5].Baujahr);

end;
            end;
            end;



wie kann ich denn diese tabelle dazu bringen das sie mir nur die daten anzeigt die die ich für das einzelnen Fahrzeuge eingetragen habe
ihc hoff mal das man dasb jetzt wenigstens n bissel versteht... :?

Moderiert von user profile iconAXMD: Code- durch Delphi-Tags ersetzt.
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: Di 21.06.05 19:58 
Wie schon gesagt: so, wie der Quelltext jetzt ist, werd ich ihn nicht lesen - und wahrscheinlich auch niemand anders. Außerdem ist nicht Kommentar drin.

AXMD