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 public 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..5] of 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
0: begin KFZFeld[Laufvar].KFZ:=PKW; form2.label1.caption:='Anzahl der Sitze'; form2.edit2.text:='******************************'; form2.edit2.readonly:=true; form2.showmodal; form2.label3.caption:=''; form2.label4.caption:=''; end;
1: begin 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;
2: begin 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; end;
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. |