Autor Beitrag
JayEff
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: Fr 11.02.05 19:52 
Hi Leute...

Ich hab folgenden Text:
ausblenden Quelltext
1:
1,2,3+4,5,6					

ich will nun das dieser string in 2 strings genau am + aufgeteilt wird.
ausblenden Quelltext
1:
2:
1,2,3
4,5,6


zweck: das ganze soll als CommaText eigenschaft von 2 Listboxes zugewiesen werden:
ausblenden Quelltext
1:
2:
3:
4:
LB1:  LB2:
1     4
2     5
3     6


Mein Ansatz:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
noten := ini.ReadString(pupil.Items[pupil.ItemIndex],
   subject.Items[subject.ItemIndex], '');
mark1.Items.CommaText := StringReplace(copy(noten, 1, pos('+', noten)), '+', '', [rfReplaceAll]);
mark1.Items.CommaText := StringReplace(mark1.Items.CommaText, ',,', ',', [rfReplaceAll]);

mark2.Items.CommaText := StringReplace(AnsiRightStr(noten, pos('+', noten) - 3), '+', '', [rfReplaceAll]);
mark2.Items.CommaText := StringReplace(mark2.Items.CommaText, ',,', ',', [rfReplaceAll]);

aber das klappt nicht! die TListBox mark2 wird nicht gefüllt!

wo ist nur der Fehler? ich habe schon viel umprobiert... :(

Bin für jede Hilfe dankbar! (Belohnung: die zahl, die da unter eurem Namen steht, wird pro Beitrag um 1 erhöht... :D)

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.


Zuletzt bearbeitet von JayEff am Fr 11.02.05 20:22, insgesamt 1-mal bearbeitet
Kroni
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 720

Win 98, Win ME, Win2k, Win XP
D3 Pro
BeitragVerfasst: Fr 11.02.05 20:03 
also ich habe das ganze mal mit nem punkt gemacht, der als trennungszeichen dient....
der code schaut so aus:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
procedure TForm1.Button1Click(Sender: TObject);
var start,i,z,anzahl:integer;
    text,wort:string;
    speicher:array[1..10] of string;
begin
start:=1;
text:=edit1.text+'.';
wort:='';
anzahl:=0;
for  i:=1 to length(text) do
  begin
  if(text[i]='.') then
    begin
    for z:=start to (i-1) do
      begin
      wort:=Wort+text[z];
      end;
     inc (Anzahl);
     speicher[anzahl]:=wort;
     start:=i+1;
     wort:='';
     end;
  end;
for i:=1 to 10 do
  memo1.lines.add(speicher[i]);

end;

ist aber noch nich gegen alles abgesichert, zb doppeltes komma usw.....
na ja kannts ja mal probiern!
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Fr 11.02.05 20:03 
so ein blödsinn.
mach lieber so:
ausblenden Delphi-Quelltext
1:
2:
mark1.Items.CommaText := copy(noten, 1, pos('+', noten)-1));
mark2.Items.CommaText := copy(noten, pos('+', noten)+1),length(noten));
Kroni
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 720

Win 98, Win ME, Win2k, Win XP
D3 Pro
BeitragVerfasst: Fr 11.02.05 20:10 
hey das ist kein blödsinn!
das war einfach nur ein
"Wie würde ich das püer hand machen, den text aufspalten"
und das ganze dann für den computer...das waren FÜNF MINUTEN die mir das progg gekostet habe, also stempel das doch nit gleich als blödsinn ab!^^
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Fr 11.02.05 20:11 
guck mal auf die zeit. unsere beiden posts kamen beide in selber minute.
das blödsinn bezog sich auf die krasse methode die jayeff gewählt hat.
Kroni
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 720

Win 98, Win ME, Win2k, Win XP
D3 Pro
BeitragVerfasst: Fr 11.02.05 20:18 
ach so ja....
ok sorry dass ich dir boshaftigkeit untestellt habe
und SORRY WEGEN OFFTOPIC
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Fr 11.02.05 20:26 
Moin!

Vorschlag:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
var
  temp: TStringList;

temp := TStringList.Create;
temp.Delimiter := '+';
temp.DelimitedText := ini.ReadString(pupil.Items[pupil.ItemIndex],subject.Items[subject.ItemIndex], '');

mark1.Items.CommaText := temp.Strings[0];
mark2.Items.CommaText := temp.Strings[1];

Passt besser zu .CommaText, finde ich. :wink:

cu
Narses
JayEff Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: Fr 11.02.05 20:28 
wahrscheinlich irgent ein blöder tippfehler, jedenfalls hab ichs am anfang auch so ähnlich ohne ansirightstring versucht.. nun, es scheint zu klappen :D danke!

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Fr 11.02.05 20:31 
welche lösung hast du denn nun gewählt ? :?:
JayEff Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2971

Windows Vista Ultimate
D7 Enterprise
BeitragVerfasst: Fr 11.02.05 20:42 
ausblenden Delphi-Quelltext
1:
2:
mark1.Items.CommaText := copy(noten, 1, pos('+', noten)-1));   
mark2.Items.CommaText := copy(noten, pos('+', noten)+1),length(noten));

die... wenn ich das mit dem delimiter nur vorher gewusst hätt ^^ nicht schlecht. aber ich hätte auch einfach das + mit einem #13#10 ersetzen können, wenn ichs recht überleg. also auch mit einer temporären variable...

_________________
>+++[>+++[>++++++++<-]<-]<++++[>++++[>>>+++++++<<<-]<-]<<++
[>++[>++[>>++++<<-]<-]<-]>>>>>++++++++++++++++++.+++++++.>++.-.<<.>>--.<+++++..<+.