Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Variablenübergabe - ich verzweifle (https://www.delphipraxis.net/112333-variablenuebergabe-ich-verzweifle.html)

raena 19. Apr 2008 13:22

Re: Variablenübergabe - ich verzweifle
 
Hallo MuhKuh

könntest du vielleicht an einem simplen Beispiel zeigen wie das geht?

:roll:

Die Muhkuh 19. Apr 2008 13:32

Re: Variablenübergabe - ich verzweifle
 
Hi,

ist mal aus dem Kopf getippt:

Delphi-Quellcode:
unit Main;

interface

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

type
  TForm3 = class(TForm)
    Button1: TButton;
   
    procedure Button1Click(Sender: TObject);

  private
    { Private declarations }
  public
    { Public declarations }
  end;
var
  FormMain: TForm3;
implementation
{$R *.dfm}

procedure TForm3.Button1Click(Sender: TObject);
begin
  with TForm5.Create(Application) do
  begin
    try
      MemoText := 'Das ist ein Test';
      ShowModal;
    finally
      Free;
    end;
  end;
end;
end.
Delphi-Quellcode:
unit Sub;

interface

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

type
  TForm5 = class(TForm)
    Memo1: TMemo;
  private
    { Private declarations }
    function GetMemoText: String;
    procedure SetMemoText(const Value: String);
  public
    property MemoText: String read GetMemoText write SetMemoText;
  end;

implementation
{$R *.dfm}

function TForm5.GetMemoText: String;
begin
  Result := Memo1.Text;
end;

procedure TForm5.SetMemoText(const Value: String);
begin
  Memo1.Text := Value;
end;

end.

raena 19. Apr 2008 13:45

Re: Variablenübergabe - ich verzweifle
 
vielen dank fuer die Antwort. Ich werde es gleich mal ausprobieren und mich dann nochmal melden.

:stupid:

DP-Maintenance 19. Apr 2008 16:22

DP-Maintenance
 
Dieses Thema wurde von "Matze" von "Programmieren allgemein" nach "Object-Pascal / Delphi-Language" verschoben.
Delphi-Frage

raena 19. Apr 2008 17:19

Re: Variablenübergabe - ich verzweifle
 
Hi Muh Kuh,

jepp es klappt :bounce2: vielen Merci.
Manche einfach erscheinende Dinge kosten oft viel Schweiss.
Ich habe die Sache jetzt mal für den "Transfer" von ListBoxen umgebogen.

Vielen Dank.

Delphi-Quellcode:
unit Main;

interface

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

type
  TForm3 = class(TForm)
    Button1: TButton;
    ListBoxMain: TListBox;

    procedure Button1Click(Sender: TObject);

  private
    { Private declarations }
  public
    { Public declarations }
  end;
var
  FormMain: TForm3;

implementation
{$R *.dfm}
procedure TForm3.Button1Click(Sender: TObject);
var
  i: integer;
begin
  with TForm5.Create(Application) do
  begin
    try
      ListBoxMain.Items[0]:='erster eintrag';
      ListBoxMain.Items[1]:='zweiter eintrag';
      ListBoxMain.Items[2]:='noch ein eintrag';
      listboxtrans:=listboxmain;
      ShowModal;
    finally
      Free;
    end;
  end;
end;
end.
Delphi-Quellcode:
unit Sub;

interface

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

type
  TForm5 = class(TForm)
    ListBox1: TListBox;
  private
    function GetListBox(): Tlistbox;
    procedure SetListBox(const Value: TListBox);
  public
    property ListBoxTrans: TListBox read GetListBox write SetListBox;
  end;
     var FormSub: TForm5;
implementation
{$R *.dfm}


function TForm5.GetListBox: TListBox;
begin
GetListBox:= listbox1;
end;

procedure TForm5.SetListBox(const Value: TListBox);
var i:integer;
begin
 for i := 0 to value.Count - 1 do ListBox1.Items[i]:=value.Items[i];
end;

end.

Klaus01 19. Apr 2008 18:11

Re: Variablenübergabe - ich verzweifle
 
Ich denke, dies:

Delphi-Quellcode:
procedure TForm5.SetListBox(const Value: TListBox);
var i:integer;
begin
  for i := 0 to value.Count - 1 do
    ListBox1.Items[i]:=value.Items[i];
 end;
kann man durch das:

Delphi-Quellcode:
procedure TForm5.SetListBox(const Value: TListBox);

begin
  Listbox1.items.assign(Value.items);
 
end;
ersetzen.

Grüße
Klaus

raena 20. Apr 2008 10:22

Re: Variablenübergabe - ich verzweifle
 
Danke Klaus
Delphi-Quellcode:
 ListboxFields.items.assign(Value.items);
geht auch. Das hatte ich schonmal probiert, hat aber wegen eines anderen Fehlers nicht gefunzt.

Merci :corky:


Alle Zeitangaben in WEZ +1. Es ist jetzt 11:18 Uhr.
Seite 2 von 2     12   

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz