Autor Beitrag
megaman7de
Hält's aus hier
Beiträge: 10

Win XP Prof.
Delphi 2005
BeitragVerfasst: Mi 11.08.04 20:44 
hallo,

wie kann ich in funktionen auf z.B. Edit1.Text Zugreifen ???
ich meine
ausblenden Delphi-Quelltext
1:
2:
3:
4:
procedure TForm1.Button1Click(Sender: TObject);
begin
  showmessage(Edit1.Text);
end;

funktioniert aber
ausblenden Delphi-Quelltext
1:
2:
3:
4:
function sm(): string;
begin
  showmessage(Edit1.Text);
end;


funktioniert schon nicht mehr weil mir der compiler
Zitat:
[Fehler] Unit1.pas(29): Undefinierter Bezeichner: 'Edit1'

auspuckt.

woran liegt das ???

Moderiert von user profile iconTino: Delphi- & Quote-Tags hinzugefügt.
Moderiert von user profile iconTino: Topic aus Sonstiges verschoben am Do 12.08.2004 um 10:18
DarkHunter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 477

Win XP
D3 Prof, D2005 PE
BeitragVerfasst: Mi 11.08.04 20:48 
nen die function mal in
ausblenden Delphi-Quelltext
1:
function tform1.sm():string;					

um

und trage
ausblenden Delphi-Quelltext
1:
function sm():string;					

als public declaration ein....
megaman7de Threadstarter
Hält's aus hier
Beiträge: 10

Win XP Prof.
Delphi 2005
BeitragVerfasst: Mi 11.08.04 21:04 
was soll ich konkret bei public declaration reinschreiben ?
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Do 12.08.04 09:17 
Hallo megaman7de und :welcome: hier im Delphi-Forum.de!

Die Funktion sm ist bei der Form noch nicht bekannt und muss deshalb definiert werden:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
Type
  tForm1 = Class (TForm);
    { ... }
    private
      function sm(): String;

Die Klammern kannst du dir auch sparen :-D

Gruß
Tino
megaman7de Threadstarter
Hält's aus hier
Beiträge: 10

Win XP Prof.
Delphi 2005
BeitragVerfasst: Do 12.08.04 12:00 
so leid es mir tut aber es funkioniert immer noch nicht... :-(
hier der komplette code:

ausblenden volle Höhe 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:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    Edit1: TEdit;
    procedure Button1Click(Sender: TObject);
  private
    function sm(): String;
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

function sm(): String;
begin
  ShowMessage(Edit1.Text);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  showmessage(Edit1.Text);
end;

end.


Moderiert von user profile iconKlabautermann: Code durch Delphi-Tags ersetzt.
Tino
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Veteran
Beiträge: 9839
Erhaltene Danke: 45

Windows 8.1
Delphi XE4
BeitragVerfasst: Do 12.08.04 12:25 
Sieh dir mal die beiden Methoden an:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
implementation   

{$R *.dfm}   

function sm(): String;   

{...}

procedure TForm1.Button1Click(Sender: TObject);

Siehst du den Unterschied? Worher soll Delphi wissen das die Funktion sm zum Objekt TForm1 gehört?

Gruß
Tino
megaman7de Threadstarter
Hält's aus hier
Beiträge: 10

Win XP Prof.
Delphi 2005
BeitragVerfasst: Do 12.08.04 18:28 
ahhhhhhhhhhhhhhhhhhh jetzt funzt's !!!!!!!! juhuuuuu
im prinzip ist es ja so wie es DarkHunter schon gesagt hatte...
danke für die geduld
raven_22
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 95

Win XP pro
D7 Enterprise
BeitragVerfasst: So 15.08.04 10:27 
Es geht aber auch so ! :wink:

LG raven 8)

ausblenden Delphi-Quelltext
1:
2:
3:
4:
function sm: string;
begin
  showmessage(Form1.Edit1.Text);
end;

_________________
---_-= raven_22 =-_---
raziel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2453

Arch Linux
JS (WebStorm), C#, C++/CLI, C++ (VS2013)
BeitragVerfasst: So 15.08.04 10:58 
Mit dem Punkt 1. hier hab ich nicht gemeint, dass Du einfach noch einen Thread erstellen sollst :roll:
Um den Topic (=Titel) eines Threads zu ändern genügt es, auf den user defined image-Button zu klicken und den Titel zu ändern...
@raven_22: nein, so geht es nicht, wenn megaman7de die funktion im public bereich der form1 deklariert muss er sie auch mit "function tform1." implementieren.

raziel

_________________
JSXGraph
raven_22
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 95

Win XP pro
D7 Enterprise
BeitragVerfasst: So 15.08.04 11:09 
Sorry, habe sicher nicht richtig gelesen ! :oops:

_________________
---_-= raven_22 =-_---