Autor Beitrag
schermerbua
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 63

Win XP

BeitragVerfasst: So 15.05.05 12:19 
wie kann ich bei klick auf einen button einen vordefinierrten string(z.b hallo) durch einen anderen ersetzen(z.b tschüs)?


Zuletzt bearbeitet von schermerbua am So 15.05.05 15:19, insgesamt 1-mal bearbeitet
Tobias1
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 454

Win 98, XP Prof
D3 Prof, D2005 Prof
BeitragVerfasst: So 15.05.05 12:21 
Meinst du so?
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
var
s:string;

procedure button1click(...)
begin
s:='Tschüss';
end;

_________________
Auch das schlechteste Buch hat seine gute Seite: die letzte. (John Osborne)
patrick
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 1481

WIN2k, WIN XP
D6 Personal, D2005 PE
BeitragVerfasst: So 15.05.05 12:23 
den alten wert einfach überschreiben, wie es tobias1 beschrieben hat :D

_________________
Patrick
im zweifelsfall immer das richtige tun!!!
Spieler1
ontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 469


D6 Pers
BeitragVerfasst: So 15.05.05 12:36 
Im Titel ist ein Tippfehler, den könnte man ja evtl. mal korrigieren. ;)
schermerbua Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 63

Win XP

BeitragVerfasst: So 15.05.05 15:18 
nein, hab mich falscha usgedrückt, sorry.
also, wenn ich auf einen button klicke, sollen alle strings mit dem wert hallo mit dem wert tschüs ersetzt5 werden. da gibts irgendwie sowas wie replayestring oder so, aber ich weiß nicht wie ich das anwenden soll!
Fabian W.
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1766

Win 7
D7 PE
BeitragVerfasst: So 15.05.05 15:20 
Wie, ALLE Strings??? Wirklich alle? Buttonscaptions, Variblen, usw?
Bitte drücke dich genauer aus. :?!?:
Spieler1
ontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 469


D6 Pers
BeitragVerfasst: So 15.05.05 15:29 
Danke für's Korrigieren des Titels. Das erleichtert auch die Suche nach dem Thread. :)
Fabian W.
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1766

Win 7
D7 PE
BeitragVerfasst: So 15.05.05 15:31 
Warum willst'de den den Suchen, du hast dich doch schon drin verewigt. :wink:
schermerbua Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 63

Win XP

BeitragVerfasst: So 15.05.05 15:47 
es sollte ein gewisser string in einem memo feld ersetzt werden!
aber wenn ich nur einen ersetzen lasse könnts doch passieren, dass wenn der string 2 mal existiert,der falsche string ersetzt wird oder?
Fabian W.
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1766

Win 7
D7 PE
BeitragVerfasst: So 15.05.05 15:58 
Kommt drauf an wie du "falsch" definierst. Also du willst nen String in nem Memo erstetzen?
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
For a := 0 to memo1.lines.count do
  begin
  if Memo1.lines[a] = 'hallo' then
    begin
    Memo1.lines[a] := 'tschüss';
    break; //Nur wenn du das erste ersetzen willst
    end;

  end;
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: So 15.05.05 16:26 
Je nach Anwendungsbereich das hier:
ausblenden Delphi-Quelltext
1:
 Memo1.Text := StringReplace(Memo1.Text, 'hallo''tschüss', [rfReplaceAll, rfIgnoreCase]);					

Oder wenn du Wortgrenzen auch noch berücksichtigen willst, siehe hier.