Autor Beitrag
rob87
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 461

Win Me, Win XP Home, Win XP Prof
Delphi 2007 Enterprise
BeitragVerfasst: Mi 08.08.07 11:00 
Mahlzeit!

Ich habe in einem Formular eine Variable deklariert und würde diese nun gerne in mehreren anderen Formularen verändern.

Wie mach ich das?

Code:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
unit {...};

interface

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

type
{...}
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
{...}
  kurs : double;

implementation
{...}
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19346
Erhaltene Danke: 1754

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Mi 08.08.07 11:08 
Einfach den Namen der Unit vor den Variablennamen stellen (also da, wo du die verwenden willst), also hier Unitx.kurs := 2;.
(Und natürlich die Unit einbinden.)

Dafür muss die Variable dort definiert sein, wo du es jetzt getan hast, also oberhalb von implementation (unterhalb wäre in jedem Fall nur für diese Unit).
rob87 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 461

Win Me, Win XP Home, Win XP Prof
Delphi 2007 Enterprise
BeitragVerfasst: Mi 08.08.07 12:12 
Des hab ich eigentlich gemacht.

Ok. Hab was übersehen... Danke