Autor Beitrag
rizor
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 209

WIN XP
Delphi 2005 PE, Visual C++
BeitragVerfasst: So 15.10.06 13:31 
Hallo,

ich möchte, dass die Länge eines Edits im Label angegeben wird.
Mein Programm sieht folgendermaßen aus:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
procedure TForm1.EfunktionChange(Sender: TObject);
begin
  l:=0;
  while l<>length(Efunktion.Text) do
  begin
    l:=l+1;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Label1.Caption:=IntToStr(l);
end;


l ist global definiert.
Ich bekomme aber keine Ausgabe, wenn ich etwas eingebe.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
procedure TForm1.EfunktionChange(Sender: TObject);
begin
  l:=length(Efunktion.text);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Label1.Caption:=IntToStr(l);
end;


Hab ich auch schon versucht.

Woran kann es liegen, dass er mir die Länge nich angibt?
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: So 15.10.06 13:38 
Sorry, aber ich verstehe deine Logik im ersten Codebeispiel nicht. Du hast eine Schleife, die die Anzahl der Zeichen zählt? :gruebel: Warum nimmste du nicht gleich l := Length(edit1.text) ?

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
ZeitGeist87
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1593
Erhaltene Danke: 20

Win95-Win10
Delphi 10 Seattle, Rad Studio 2007, Delphi 7 Prof., C++, WSH, Turbo Pascal, PHP, Delphi X2
BeitragVerfasst: So 15.10.06 13:38 
Hallo!

Mit Länge des Edits meinst du wie viele Zeichen eingeben wurden richtig?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
//bei deinem Edit im OnChange-Ereignis schreibst du folgendes
...
label1.caption:= inttostr(length(MeinEdit.text));
...

//willst du es Lieber auf ButtonClick machen
label1.caption:= inttostr(length(MeinEdit.text));


LG
Stefan

_________________
Wer Provokationen, Ironie, Sarkasmus oder Zynismus herauslesen kann soll sie ignorieren um den Inhalt meiner Beiträge ungetrübt erfassen zu können.
rizor Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 209

WIN XP
Delphi 2005 PE, Visual C++
BeitragVerfasst: So 15.10.06 13:44 
Ja, das meinte ich.
Im ersten Code hatte ich es mal anders versucht.
Delphi hat ja manchmal so eine seltsame Logik.

Mit Label...:=IntToStr(length(Edit.text));

geht leider nicht.
gibt er immer noch net aus.
ZeitGeist87
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1593
Erhaltene Danke: 20

Win95-Win10
Delphi 10 Seattle, Rad Studio 2007, Delphi 7 Prof., C++, WSH, Turbo Pascal, PHP, Delphi X2
BeitragVerfasst: So 15.10.06 13:50 
ich kann mir denen wo der fehler liegt

wie heißt dein edit?

und wie heißt dein label?

derNameDeineLabels.caption:= inttostr(length(derNameDeinesEdits.text));

LG
Stefan

_________________
Wer Provokationen, Ironie, Sarkasmus oder Zynismus herauslesen kann soll sie ignorieren um den Inhalt meiner Beiträge ungetrübt erfassen zu können.
rizor Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 209

WIN XP
Delphi 2005 PE, Visual C++
BeitragVerfasst: So 15.10.06 13:58 
Mein Edit heißt Efunktion und mein Label Label1

so habe ich es auch gemacht.
Daran liegt es nicht.
ZeitGeist87
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1593
Erhaltene Danke: 20

Win95-Win10
Delphi 10 Seattle, Rad Studio 2007, Delphi 7 Prof., C++, WSH, Turbo Pascal, PHP, Delphi X2
BeitragVerfasst: So 15.10.06 14:01 
anhang
Einloggen, um Attachments anzusehen!
_________________
Wer Provokationen, Ironie, Sarkasmus oder Zynismus herauslesen kann soll sie ignorieren um den Inhalt meiner Beiträge ungetrübt erfassen zu können.
ZeitGeist87
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1593
Erhaltene Danke: 20

Win95-Win10
Delphi 10 Seattle, Rad Studio 2007, Delphi 7 Prof., C++, WSH, Turbo Pascal, PHP, Delphi X2
BeitragVerfasst: So 15.10.06 14:03 
nochmal
Einloggen, um Attachments anzusehen!
_________________
Wer Provokationen, Ironie, Sarkasmus oder Zynismus herauslesen kann soll sie ignorieren um den Inhalt meiner Beiträge ungetrübt erfassen zu können.
rizor Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 209

WIN XP
Delphi 2005 PE, Visual C++
BeitragVerfasst: So 15.10.06 19:01 
Danke.
Hat mir geholfen