Autor Beitrag
FloBue
Hält's aus hier
Beiträge: 5



BeitragVerfasst: So 03.06.07 17:08 
hallo ich hab mal wieder ein Problem:
Wie kann ich eine Prozedur die in Unit steht, in Unit2 benutzen. Ich hab schon alle Verfahren ausprobiert, die im Forum standen.
Danke es is sehr dringend Danke.....Flobue


Moderiert von user profile iconChristian S.: Topic aus VCL (Visual Component Library) verschoben am So 03.06.2007 um 17:14
jakobwenzel
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1889
Erhaltene Danke: 1

XP home, ubuntu
BDS 2006 Prof
BeitragVerfasst: So 03.06.07 17:35 
Die Unit muss eingebunden sein und die Prozedur muss öffentlich sein.

_________________
I thought what I'd do was, I'd pretend I was one of those deaf-mutes.
oldmax
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 380


D3 Prof, D4 Prof
BeitragVerfasst: Di 05.06.07 09:33 
Hi
Ich nehme für solche Proceduren und Functions nicht visuelle Forms z. B. eignet sich das Datenmodul dafür. Dort werden die Proceduree und Functions unter Publik deklariert und anschließend im Implementationsteil programmiert.
zb.
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:
23:
24:
MyDatamodul
Public
  .....
  Function MyFunction1(Übergabewerte: VariablenTyp): Variablentyp;
  ....
  Procedure MyProcedure(Übergabewerte: VariablenTyp);
  ...

Implementation

Function TMyDatamodul.MyFunction1(Übergabewerte: VariablenTyp): Variablentyp;
Begin
  ....
  ....
  Result :=irgendwas;
end;


  ....
Procedure TMyDatamodul.MyProcedure(Übergabewerte: VariablenTyp);
Begin

  mein Programm
end;


Diese rufst du in anderen Formularen mit vorangestelltem Variablennamen der Form
z. Aufruf in einem anderen Formular:

ausblenden Delphi-Quelltext
1:
Ergebnis:=MyDatamodul.MyFunction(....);					

oder
ausblenden Delphi-Quelltext
1:
MyDatamodul.MyProcedure;					

Beachte aber, das du in diesen Procedures keine Objekte des aufrufenden Formulares ansprichst.
Gruß oldmax

_________________
Zier dich nich so, ich krieg dich schon....