Autor Beitrag
GI_PC
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 34



BeitragVerfasst: Do 22.02.07 19:46 
Hallo Leute

Ich habe hier ein Kode, wo man den satz bis ';' kopiert, von ein List box auf ein andere kopieren, ich verstehe es aber nicht so richtig.
Kann ihr mir bitte erklären? Geht es auch anders?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
procedure TForm1.btntransfertClick(Sender: TObject);
var I1,I2: integer;
    X,s: string;
begin
    I1:=0;
    while I1 < lblec.items.count do
       begin
         s:= lblec.items[I1];
         I2:=1;
         X:=' ';
           while X <>';' do
              begin
               I2:=I2+1;
               X:= copy (s,I2,1);
             end;
           lbnom.items.append(copy (S,1,I2-1));
           lbchi.items.append(copy (S,I2+1,length(s)-I2));
           I1:=I1+1
       end;
end;


Danke GI_PC

Moderiert von user profile iconChristian S.: Delphi-Tags hinzugefügt
Mr_Sven
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 38


D7 Prof., C# (VS 2008)
BeitragVerfasst: Do 22.02.07 20:29 
Wat umständlich
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
uses strUtils;

procedure TForm1.btntransfertClick(Sender: TObject);  
var I1,I2: integer;  
    X,s: string;  
begin  
    I1:=0;  
    while I1 < lblec.items.count do  
       begin 
        s:=lblec.items[I1];
        I2:=pos(s,';'); 
        lbnom.items.append(LeftStr(s,I2-1));
        lbchi.items.append(RightStr(s,Length(s)-I2));
       end;  
end;


so besser?

Gruß Sven
GI_PC Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 34



BeitragVerfasst: Do 22.02.07 20:34 
ja das sieht schon viel einfacher aus, aber was ist "LeftStr" und "RightStr"??
Jacer
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 105

Windows 7, Vista, Ubuntu
HTML,CSS,PHP,Delphi 7
BeitragVerfasst: Do 22.02.07 20:37 
user profile iconGI_PC hat folgendes geschrieben:
ja das sieht schon viel einfacher aus, aber was ist "LeftStr" und "RightStr"??


LeftStr ist der Teil des Strings vor dem ";" und RightStr ist der Teil nach dem Semikolon!

_________________
A look in the eyes often says more than a hundred words could ever express.
GI_PC Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 34



BeitragVerfasst: Do 22.02.07 20:43 
ach so, ok,

aber mein program läuft nicht, mit diese Methode.
Jacer
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 105

Windows 7, Vista, Ubuntu
HTML,CSS,PHP,Delphi 7
BeitragVerfasst: Do 22.02.07 21:59 
Dann poste mal bitte deinen momentanen Quellcode!
Da sieht man das meistens am Besten!

_________________
A look in the eyes often says more than a hundred words could ever express.
GI_PC Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 34



BeitragVerfasst: Do 22.02.07 22:10 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
procedure TForm1.btntransfertClick(Sender: TObject);
var I1,I2: integer;
    X,s: string;
begin

       I1:=0;  
    while I1 < lblec.items.count do  
       begin 
        s:=lblec.items[I1];
        I2:=pos(s,';'); 
        lbnom.items.append(LeftStr(s,I2-1));
        lbchi.items.append(RightStr(s,Length(s)-I2));
       end;  
end;


Moderiert von user profile iconraziel: Delphi-Tags hinzugefügt
jakobwenzel
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1889
Erhaltene Danke: 1

XP home, ubuntu
BDS 2006 Prof
BeitragVerfasst: Do 22.02.07 22:26 
I1 wird nicht erhöht.
And Ende der Schleife muss noch: Inc(i1);


PS: Wenn du den Fehler sagst, wäre es besser.

_________________
I thought what I'd do was, I'd pretend I was one of those deaf-mutes.
Mr_Sven
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 38


D7 Prof., C# (VS 2008)
BeitragVerfasst: Do 22.02.07 22:47 
sry, mein Fehler, hab übersehn, dass das ne while Schleife is