Autor Beitrag
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 27.05.06 12:33 
Hi,
ich habe hier ein Problem:
In Form 2 wird in ein Edit ein Name eingeben
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
  public
    { Public-Deklarationen }
    a, b: String;
  end;

var
  Form2: TForm2;

implementation

{$R *.dfm}

procedure TForm2.FormCreate(Sender: TObject);
begin
 Edit1.Text := a;
 Edit2.Text := b;
 Label1.Caption := 'Du musst deinen Spielernamen eingeben.' + #10#13 + 'Spieler 1 spielt "X" und Spieler 2 spielt "O"!';
end;


Hier in Form 1 kommt dann der Fehler:
Zitat:
Zugriffsverletzung bei Adresse 0046A665 in Modul "Programm.exe". Lesen von Adresse 00000310.

bei dem Quelltext:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
procedure TForm1.FormCreate(Sender: TObject);
var frmHilfe: TForm2;
begin
  frmHilfe := TForm2.Create(nil);
  frmHilfe.ShowModal();
  Form2.Edit1.Text := Form2.a;//Hier ist vermutlich der Fehler
  Form2.Edit2.Text := Form2.b;//was muss man anders machen 
  A1 := 2; 
  A2 := 2;
  A3 := 2;
  A4 := 2;
  A5 := 2;
  A6 := 2;
  A7 := 2;
  A8 := 2;
  A9 := 2;
  NZ := 2;
  Z  := 2;
end;

Und so will ich das in Edit1 oder Edit2 eingegebene ausgeben:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
prodzedure TForm1.Button1Click(Sender: TObject);
begin
Label1.Caption := Form2.a + 'blabla'
end;

Hier wird aber nichts angezeigt.
Danke im voraus
Leuchtturm

Ps.: ich weiß das ich viel geschrieben habe :mrgreen:

_________________
Ich bin dafür verantwortlich was ich sage - nicht dafür was du verstehst.
The Who
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 25

Win XP Prof
D3 Prof, D8, D7E
BeitragVerfasst: Sa 27.05.06 12:41 
Versuch das mal hier mit:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
procedure TForm1.FormCreate(Sender: TObject);
var frmHilfe: TForm2;
begin
  frmHilfe := TForm2.Create(nil);
  frmHilfe.ShowModal();
  <span style="color: red">frmHilfe</span>.Edit1.Text := Form2.a;//Hier ist vermutlich der Fehler
  <span style="color: red">frmHilfe</span>.Edit2.Text := Form2.b;//was muss man anders machen 
  A1 := 2; 
  A2 := 2;
  A3 := 2;
  A4 := 2;
  A5 := 2;
  A6 := 2;
  A7 := 2;
  A8 := 2;
  A9 := 2;
  NZ := 2;
  Z  := 2;
end;
Fabian W.
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1766

Win 7
D7 PE
BeitragVerfasst: Sa 27.05.06 12:44 
Du führst den Code im OnCreateereignis des F1 aus, da besteht F2 doch noch garnicht -> Zugriffsverletzung ;)
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Sa 27.05.06 12:48 
Der Fehler liegt, wie schon user profile iconThe Who angedeutet hat am nichts instantiiertem Form2. Diese Variable ist stndadrdmäßig in der Unit von TForm2 deklariert worden. Du erzeugst zwar eine Instant von TForm2 west dieese aber der Variable frmHilfe zu.

_________________
Markus Kinzler.
Regan
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 2157
Erhaltene Danke: 72


Java (Eclipse), Python (Sublimetext 3)
BeitragVerfasst: Sa 27.05.06 13:27 
kannst du nich einfach direkt auf die edit-felder draufzugreifen.
ausblenden Delphi-Quelltext
1:
Label1.Caption := Form2.Edit1.text + 'blabla'					

sag bescheid wenn des raushast --> ich freu mich schon auf die nächste version TicTacToe.
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Sa 27.05.06 13:32 
Hier ist das selbe Problem Form2 ist nicht definiert.

_________________
Markus Kinzler.
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: Sa 27.05.06 13:38 
hast du unit2 auch bei den uses eingebunden?
Fabian W.
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1766

Win 7
D7 PE
BeitragVerfasst: Sa 27.05.06 14:11 
Wenn Form1 Das Hauptformular ist gibt es noch garnix von Form2, das könnt ihr drehen und wenden wie ihr wollt, der Code kann SO nicht bleiben - das OnCreateEvent eignet sich numal nicht dafür... :wink:
Leuchtturm Threadstarter
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 27.05.06 14:20 
@ DelphiAnfänger: ja
@ mkinzler: kannst du mir das bitte genauer erklären
@ Regan: das Funktioniert mit ein paar änderungen

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