Autor Beitrag
Krefti
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 164

Win XP/Vista/Win7/ubuntu
Delphi 7/2006/2009 Pro
BeitragVerfasst: Do 06.04.06 10:41 
moin zusammen..hab zwei kleine probleme und zwar:

1. ich lasse vom nutzer kommawerte in ein edit eingeben. diese möchte ich in einen bestehenden String an eine bestimmte stelle einbauen. wie kann ich des machen???

2. wie kann ich im programmcode errechnete werte in den gleichen string wie oben an eine bestimmte stelle einbauen??

find dazu irgendwie nichts passendes..

vielen dank scho ma für eure hilfe!!
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Do 06.04.06 10:45 
Soll der Wert eingefügt werde oder soll ein Teilstring durch ihn ersetzt werden?

_________________
Markus Kinzler.
Krefti Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 164

Win XP/Vista/Win7/ubuntu
Delphi 7/2006/2009 Pro
BeitragVerfasst: Do 06.04.06 10:48 
er soll ein teil des strings ersetzt werden.. und des ganze wird mehrmals an verschiedenen stellen gemacht..
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Do 06.04.06 11:00 
Einfügen wäre einfacher, aber so müßte es gehen:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
var
  s, s2: string;
begin
   s := 'Hallo Welt !';
   s2 := 'Mond';
   s := copy(s, 1,6)+'Mond'+copy( s, 7+length(s2), length(s));
   self.Caption := s;

_________________
Markus Kinzler.
Krefti Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 164

Win XP/Vista/Win7/ubuntu
Delphi 7/2006/2009 Pro
BeitragVerfasst: Do 06.04.06 11:03 
und wie würde es mit einfügen gehen???

ich hab zahlen..dich ich entweder vorher berechnet hab oder die durch den benutzer eingebbe werde..geht es damit genauso?
mkinzler
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 4106
Erhaltene Danke: 13


Delphi 2010 Pro; Delphi.Prism 2011 pro
BeitragVerfasst: Do 06.04.06 11:09 
ausblenden Delphi-Quelltext
1:
procedure Insert(Substr: string; var Dest: string; Index: Integer);					

_________________
Markus Kinzler.
Horschdware
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 744
Erhaltene Danke: 54

Win XP Pro, Win 7 Pro x64
Delphi 7, Delphi XE, C++ Builder 5, SAP R/3
BeitragVerfasst: Do 06.04.06 11:41 
du musst halt vorher die Zahlen in strings umwandeln. Dann gehts das genauso

_________________
Delphi: XE - OS: Windows 7 Professional x64
frank-wob
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Do 06.04.06 13:42 
Hallo,

wenn du Werte in einen String einfügen möchtest, kannst du das mit Format machen.

Bsp:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
procedure TForm1.Button1Click(Sender: TObject);
var i:Integer;
    r:Real;
    s:String;
begin
 i:=15428;
 r:=145.587;
 s:='Stringlein';
 edit1.Text:=Format('ich bin integer %d ---> ich bin eine Reele Zahl %f  ---> und ich ein String %s  ',[i,r,s]);
end;

Such mal in der Delphi Hilfe! Mit Format hat man jede Menge Möglichkeiten.

Wenn du etwas in einem String ersetzen möchtest kannst du z.B. die Funktion StringReplace benutzen.

Hier noch ein Beispiel:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
procedure TForm1.Button4Click(Sender: TObject);
Var s:String;
    s2:String;
begin
 s:='Hallo ich bin ein String';
 s2:=StringReplace(s,'ich bin','du bist',[rfReplaceAll, rfIgnoreCase]);
 edit1.Text:=s2;
end;



Gruß Frank
Krefti Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 164

Win XP/Vista/Win7/ubuntu
Delphi 7/2006/2009 Pro
BeitragVerfasst: Do 06.04.06 14:56 
vielen dank für eure antworten! des hilft mir schon ma weiter..wenn noch irgend ne frage auftritt meld ich mich nochma!danke!