Einzelnen Beitrag anzeigen

Blup

Registriert seit: 7. Aug 2008
Ort: Brandenburg
1.464 Beiträge
 
Delphi 12 Athens
 
#9

AW: Access variable from one form to another

  Alt 21. Aug 2013, 09:33
The solution has already been posted, again in detail:
Delphi-Quellcode:
unit unit1;

interface

type
  TForm1 = class(TForm)
    {...}
  private // <- for use self
    FMyPersonID: Integer;
    procedure Person1(ID:Integer);
  public // <- for use to other
    property MyPersonID: Integer read FMyPersonID write FMyPersonID;
  end;

var
  Form1: TForm1; // <- Instance of TForm1

implementation

Procedure TForm1.Person1(ID:Integer);<--- i want to use this value of ID in another Form
begin
  FMyPersonID := ID;
end;



unit unit2;

interface

type
  TForm2 = class(TForm)
    {...}
    procedure Button1Click(Sender: TObject);
  end;

implementation

uses
  unit1; // <- knowhow about TForm1, MyPersonID and Form1

Procedure TForm2.Button1Click(Sender: TObject);
begin
//here i want to use the value of ID from TForm1
  Form1.MyPersonID := Form1.MyPersonID + 1;

end;
  Mit Zitat antworten Zitat