Autor Beitrag
Arbengie
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 66



BeitragVerfasst: Mo 01.02.10 19:50 
Hab noch eine andere Frage...SuFu hat nichts brauchbares gefunden bei mir.

Undzwar gibt es ein Edit1 Feld und nen Button1 und nen Memo Feld. Mein Ziel ist es beim Button1-Klick, dass im Memo1 ein Text mit einer Lücke angezeigt wird und diese Lücke soll durch die Variable (diese steht halt für einen beliebigen Text aus Edit1.Text) ersetzt werden.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure TForm1.Button1Click(Sender: TObject);
begin
  x1 := Edit1.Text;

  Memo1.Lines.Add('Name: (x1)');

end;


Das kann natürlich nicht gehen weil der dann einfach "Name: (x1)" anzeigt, wie bekomme ich das den nun hin?

MfG
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Mo 01.02.10 19:54 
Schau Dir mal die Funktion Format an.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
FinnO
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1331
Erhaltene Danke: 123

Mac OSX, Arch
TypeScript (Webstorm), Kotlin, Clojure (IDEA), Golang (VSCode)
BeitragVerfasst: Mo 01.02.10 19:54 
ausblenden Delphi-Quelltext
1:
memo1.lines.add('Text ' + Edit1.Text + 'noch mehr Text.');					


Moderiert von user profile iconNarses: Delphi-Tags hinzugefügt
ffgorcky
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 573

WIN XP/2000 & 7Prof (Familie:Win95,Win98)

BeitragVerfasst: Di 02.02.10 17:01 
Also wenn icgh Dich richtig verstehe, dann möchtest Du einfach nur diese Funktion so haben:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
procedure TForm1.Button1Click(Sender: TObject);
begin
  x1 := Edit1.Text;

  Memo1.Lines.Add('Name: ('+x1+')');

end;

Das müsste doch so den Namen im dem Memo unten anfügen.
Jakob_Ullmann
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1747
Erhaltene Danke: 15

Win 7, *Ubuntu GNU/Linux*
*Anjuta* (C, C++, Python), Geany (Vala), Lazarus (Pascal), Eclipse (Java)
BeitragVerfasst: Di 02.02.10 17:52 
user profile iconArbengie, ich vermute mal, dass du von PHP oder Perl kommst? Jedenfalls kannst du in Delphi so ohne weiteres nicht einfach Variablen im String verwenden. Das, was du willst, kannst du jedenfalls sowohl über ein einfaches aneinanderreihen (konkatenieren) mit dem Operator + der Strings als auch über die Funktion Format erreichen. Das erste solltest du jedenfalls beherrschen, beim zweiten ist es nicht ganz so schlimm. :wink: