Autor Beitrag
zivi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17



BeitragVerfasst: Mo 29.05.06 20:24 
guten abend

ich hab da ma ne frage...
wenn ich ein memo fenster nach bustaben durchsuchen will und diese ersetzeten will, wie mach ich das???

mein anfang ist bei:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure TForm1.Button3Click(Sender: TObject);
var index : integer;
begin
for Index := 1 to Length(memo1.lines)
do begin
        'ä':='ae';
end;
end;


aber irgendwie hab ich nen blackout und bin mir nch nicht mal sicher ob das die richtige methode ist, um eiene buchstaben zu suchen...

bitte um hilfe...

de zivi

Moderiert von user profile iconGausi: Delphi-Tags hinzugefügt
DelphiAnfänger
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 112

Win XP, Firefox 2.0, IE6
Delphi 5 Prof., Delphi 2005 PE
BeitragVerfasst: Mo 29.05.06 20:31 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
procedure TForm1.blablub;
Var s:string;
i,vlaenge:integer;
begin
 s:=memo1.text;
 vlaenge:=length(s);
 for i:=1 to vlaenge do
 begin
  if s[i]='ä' then s[i]:='a'; //ob das mit s[i]:='ae' auch geht weiß ich nicht
 end;
 memo1.text:=s;
end;
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Mo 29.05.06 20:32 
Schau dir mal die Funktion StringReplace oder AnsiStringReplace an. Die macht das, was due willst ;-)

_________________
We are, we were and will not be.
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Mo 29.05.06 20:35 
Ich würde StringReplace nehmen

ausblenden Delphi-Quelltext
1:
StringReplace( memo,text, 'ä', 'ae', [rfReplaceAll]);					

_________________
Markus Kinzler.
zivi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17



BeitragVerfasst: Mo 29.05.06 20:42 
also hab dass mit beiden tipps ausprobiert...

einmal mit der ä in a geschichte, da meckert er, wenn ich im quelltext aus 'a' 'ae' mache, weil das ein string und kein char ist. demnach sinds inkompatible typen...

wenn ich die zweite variante nehme
1:
StringReplace( memo.text, 'ä', 'ae', [rfReplaceAll]);

dann meckert er zwar nicht, aber machen tut er auch nichts...

woran kanns liegen???


dankeschön erstmal für die hilfe...
Born-to-Frag
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1094

Win XP SP2, Win 2000 SP4
Delphi 7, 2k5
BeitragVerfasst: Mo 29.05.06 20:42 
@DelphiAnfänger: s[i] := 'ae' würde nicht gehen, da 'ae' kein Char mehr ist sondern eine Zeichenkette. Du kannst ja nicht einfach in einen Platzhalter 2Sachen reinquetschen ;)

Also lieber StringReplace :)


EDIT: lol, zu langsam :autsch:

_________________
Theorie ist wenn man alles weiß, aber nichts funktioniert. Praxis ist wenn alles funktioniert, aber niemand weiß warum.
Microsoft vereint Theorie und Praxis: Nichts funktioniert und niemand weiß warum.


Zuletzt bearbeitet von Born-to-Frag am Mo 29.05.06 20:44, insgesamt 1-mal bearbeitet
Born-to-Frag
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1094

Win XP SP2, Win 2000 SP4
Delphi 7, 2k5
BeitragVerfasst: Mo 29.05.06 20:44 
user profile iconzivi hat folgendes geschrieben:
StringReplace( memo.text, 'ä', 'ae', [rfReplaceAll]);


Versuch mal Memo1.Text := StringReplace(Memo.Text, 'ä', 'ae', [rfReplaceAll]);

_________________
Theorie ist wenn man alles weiß, aber nichts funktioniert. Praxis ist wenn alles funktioniert, aber niemand weiß warum.
Microsoft vereint Theorie und Praxis: Nichts funktioniert und niemand weiß warum.
zivi Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 17



BeitragVerfasst: Mo 29.05.06 20:59 
ihr seid perfekt...;)

okay ich muss zugeben, das war en dummer fehler, aber ich hab ja gesagt heut bin ich ein bisschen neben der spur...

vielen dank nch mal, mein problem wäre damit gelöst...

schönen abend noch, de zivi