AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Werte an andere Form übergeben

Ein Thema von Snooze · begonnen am 22. Feb 2004 · letzter Beitrag vom 22. Feb 2004
 
Benutzerbild von Manzoni
Manzoni

Registriert seit: 15. Feb 2004
Ort: Berlin
120 Beiträge
 
Delphi 7 Enterprise
 
#12

Re: Werte an andere Form übergeben

  Alt 22. Feb 2004, 18:15
hi,

globale Variablen sind für mich ein altes Pascal Relikt. In Objekt-Pascal sollte man besser objektorientierte Strukturen verwenden.
Delphi-Quellcode:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
  private
    { Private-Deklarationen }
    variable : String;
  public
    { Public-Deklarationen }
    function _variable : string;
  end;

var
  Form1: TForm1;

implementation
{$R *.dfm}
function TForm1._variable : string;
begin
  result:=variable;
end;

end.
Die andere Unit:
Delphi-Quellcode:
unit Unit2;

interface

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

type
  TForm2 = class(TForm)
    Label1: TLabel;
  private
    { Private-Deklarationen }
    procedure beispiel;
  public
    { Public-Deklarationen }
  end;

var
  Form2: TForm2;

implementation

uses Unit1;

{$R *.dfm}
procedure TForm2.beispiel;
begin
  Label1.Caption:=Form1._variable;
end;

end.
Auf den ersten Blick etwas umständlicher, aber wie ich finde auf jedenfall strukturierter.
Bob
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 10:10 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz