Autor Beitrag
hibbert
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1007

WinServer2003, Win XP, Linux
D6 Pers, D05
BeitragVerfasst: Fr 26.09.03 23:32 
Hi,
auf meiner Mainform (Form1) habe ich eine Variable ausgerechnet. Nun Möchte ich diese Variable übergeben, undzwar folgendermaßen:
Der User klickt auf einen Button und dir 2. Form wird geöffnet (Form2). Wenn der User auf den Button klickt soll die Variable übergeben werden undzwar in eine Bereits auf der 2. Form deklarierte Variable.
Also wenn die Variable auf der Form1 "a" heißt, dann soll auf der 2. Form gelten "b"="a" :wink:

thx hibbert

_________________
I kunnen väl svara endast ja eller nej
Om i viljen eller nej
maze2k
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 252

WIN 95, WIN NT 4.0, WIN 98, WIN 98SE, WIN 2000, RedHat Linux 7.3, Mandrake Linux 9.2, Knoppix Linux 3.3
D6 Pers
BeitragVerfasst: Fr 26.09.03 23:38 
Hm, wenn ich dich richtig verstehe ist dein Problem einfach. du musst nur die Variable "b" in der Form2 global definieren.
ausblenden Delphi-Quelltext
1:
2:
3:
var
  Form1 : TForm1;
  b : Integer;

beim OnClick-Event deines Buttons kommt dann rein:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.UebergebenClick(Sender: TObject);
begin
  Form2.b := a;
end;

Ich hoffe, das hilft dir :)

Moderiert von user profile iconTino: Code- durch Delphi-Tags ersetzt.

_________________
Wer das Konzept der Unendlichkeit verstehen will, muss nur das Ausmaß menschlicher Dummheit betrachten. (Voltaire)
hibbert Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1007

WinServer2003, Win XP, Linux
D6 Pers, D05
BeitragVerfasst: Fr 26.09.03 23:47 
mhh, da kommt leider ne Fehlermeldung:
Zitat:
[Fehler] Unit1.pas(33): Undefinierter Bezeichner: 'b'

und ich habe auf der 2. Form die Variable "b" global deklariert.
und diese Zeile wurde vom Compiler makiert:
Form2.b := a; und so sieht mein Quelltext aus:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure TForm1.Button1Click(Sender: TObject);
var a:integer;
begin
a:=strtoint(edit1.Text);
Form2.b := a;
form2.show;
end;

und
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
var
  Form2: TForm2;
  b:integer;

implementation

{$R *.dfm}

procedure TForm2.Button1Click(Sender: TObject);
begin
edit1.Text:=inttostr(b);
end;

was hab ich falsch gemacht :?

thx hibbert

_________________
I kunnen väl svara endast ja eller nej
Om i viljen eller nej
maze2k
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 252

WIN 95, WIN NT 4.0, WIN 98, WIN 98SE, WIN 2000, RedHat Linux 7.3, Mandrake Linux 9.2, Knoppix Linux 3.3
D6 Pers
BeitragVerfasst: Fr 26.09.03 23:58 
Argl, ich hab dir Mist erzählt, du sollst es nicht bei
ausblenden Delphi-Quelltext
1:
2:
3:
var 
  Form1 : TForm1; 
  b : Integer;

reinschreiben sondern unter
ausblenden Delphi-Quelltext
1:
2:
3:
public
    b: string;
    { Public-Deklarationen }

das müsste gehen (bei mir zumindest geht's) *g*

Moderiert von user profile iconTino: Code- durch Delphi-Tags ersetzt.

_________________
Wer das Konzept der Unendlichkeit verstehen will, muss nur das Ausmaß menschlicher Dummheit betrachten. (Voltaire)
hibbert Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1007

WinServer2003, Win XP, Linux
D6 Pers, D05
BeitragVerfasst: Sa 27.09.03 00:11 
jepp nun funzt es.

thx hibbert :D

_________________
I kunnen väl svara endast ja eller nej
Om i viljen eller nej
G-man
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 258

Win 2000, Win ME, SuSE 8.2
D5 Standard, D6 Professional
BeitragVerfasst: Mo 29.09.03 07:12 
Du kannst die Variable ja auch in eine *.ini Datei schreiben, und die Informationen dann bei Aufruf der Form auslesen lassen.
Dieser Weg würde sich aber nur bei mehereren Variablen wirklich lohnen...

_________________
...To err is human, but to really foul things up requires a computer.
hibbert Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1007

WinServer2003, Win XP, Linux
D6 Pers, D05
BeitragVerfasst: Mo 29.09.03 21:01 
ja klar, aber für eine kleine Var ist der aufwand einfach zu groß, um das mit ner *.ini zu machen :wink:

hibbert

_________________
I kunnen väl svara endast ja eller nej
Om i viljen eller nej