Autor Beitrag
Sneek
Hält's aus hier
Beiträge: 13



BeitragVerfasst: Sa 12.05.07 17:10 
Hi,
hab mittels der SuFu schon was gefunden, wo ich dachte, dass wäre der Fehler, dem ist aber nicht so.

Erstmal der Code:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
for i:=1 to 2 do
 begin
 Edit[i]:=TEdit.Create(Form1);
 with Edit[i] do
   begin
   Name:='EditA';
   Text:='12';
   Parent:=Form1;
   Top:=20;
   Left:=8;
   Height:=13;
   Width:=71
   end;
 end;


So, wenn ich das Programm nun starte möchte, meckert der Compiler in, hier Zeile 3 und 4,
"Klasse besitzt keine Standardeigenschaft".

Und jetzt könnt ich euch sicherlich schon denken, was ich will :)
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Sa 12.05.07 17:17 
Zeig mal die Deklaration des Arrays.

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Sneek Threadstarter
Hält's aus hier
Beiträge: 13



BeitragVerfasst: Sa 12.05.07 17:22 
Öhm, hab kein Array erstellt, ehrlich gesagt weiss ich auch nur so halb, was das ist :oops:
Wie sollte der denn aussehen?
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Sa 12.05.07 17:27 
Na dann zeig mal bitte den gesamten Code. Dann können wir dir auch Arrays erklären. ;)

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Sneek Threadstarter
Hält's aus hier
Beiträge: 13



BeitragVerfasst: Sa 12.05.07 17:29 
Hab mal nach Array gesucht und hab den Code jetzt wie folgt umgeändert:
(Schick jetzt mal ganzen)
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:
unit Unit1;

interface

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

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

var
  Form1: TForm1;



implementation

{$R *.dfm}



procedure TForm1.Button1Click(Sender: TObject);
var i : integer;    Edit: array [1..2] of Edit; : TEdit;
begin
for i:=1 to 2 do
 begin
 Edit[i]:=TEdit.Create(Form1);
 with Edit[i] do
   begin
   Name:='EditA';
   Text:='12';
   Parent:=Form1;
   Top:=20;
   Left:=8;
   Height:=13;
   Width:=71
   end;
 end;
end;

end.


Das alte Leid wird nun nicht mehr gemeldet, dafür aber "Konstante oder Typenbezeichner erwartet", in Zeile 34.
Leuchtturm
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1087

Win Vista, Knoppix, Ubuntu
Delphi 7 Pe, Turbo Delphi, C#(VS 2005 Express), (X)HTML + CSS, bald Assembler
BeitragVerfasst: Sa 12.05.07 17:30 
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:
unit Unit1;

interface

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

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

var
  Form1: TForm1;



implementation

{$R *.dfm}



procedure TForm1.Button1Click(Sender: TObject);
var i : integer;    Edit: array [1..2] of TEdit; // statt ...of Edit; : TEdit
begin
for i:=1 to 2 do
 begin
 Edit[i]:=TEdit.Create(Form1);
 with Edit[i] do
   begin
   Name:='EditA';
   Text:='12';
   Parent:=Form1;
   Top:=20;
   Left:=8;
   Height:=13;
   Width:=71
   end;
 end;
end;

end.

_________________
Ich bin dafür verantwortlich was ich sage - nicht dafür was du verstehst.
Sneek Threadstarter
Hält's aus hier
Beiträge: 13



BeitragVerfasst: Sa 12.05.07 17:36 
Ahh, ist irgendwie logisch :P

Starten lässt es sich jetzt, aber wenn ich auf den Button klicke, stürzt das Programm ab, mit der Fehlermeldung "Komponente mit der Bezeichnung EditA exestiert bereits.
Leuchtturm
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1087

Win Vista, Knoppix, Ubuntu
Delphi 7 Pe, Turbo Delphi, C#(VS 2005 Express), (X)HTML + CSS, bald Assembler
BeitragVerfasst: Sa 12.05.07 17:45 
Es gibt die ja auch doppelt, du gibts nämlich beiden Edits den selben namen. mache einfach:
ausblenden Delphi-Quelltext
1:
2:
3:
...
Name := 'Edit' + i;
...

_________________
Ich bin dafür verantwortlich was ich sage - nicht dafür was du verstehst.
Sneek Threadstarter
Hält's aus hier
Beiträge: 13



BeitragVerfasst: Sa 12.05.07 17:49 
Aso, die "for to do-Anweisung" geht also gleiche alle beide Werte durch?
Ich dachte pro Klick einen >.<

Gut, dann ist das Problem geklärt.
Leuchtturm
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1087

Win Vista, Knoppix, Ubuntu
Delphi 7 Pe, Turbo Delphi, C#(VS 2005 Express), (X)HTML + CSS, bald Assembler
BeitragVerfasst: Sa 12.05.07 17:56 
Das ist eine for-Schleife. Die zaählt in deinem Fall von 1 bis 2 und mach bei 1 etwas und bei 2 etwas :wink:

_________________
Ich bin dafür verantwortlich was ich sage - nicht dafür was du verstehst.