var I, J: Integer; S, S2: String; begin ListBox2.Items.BeginUpdate; try ListBox2.Items.Clear; // vider la liste avant S2 := Uppercase(Edit1.Text); // mettre le texte à rechercher ici for I := 0 to ListBox1.Items.Count - 1 do begin S := Uppercase(ListBox1.Items.Strings[I]); // on parcourt la ligne actuelle en cherchant des occurrences de S2 for J := 1 to Length(S) - Length(S2) + 1 do if Copy(S, J, Length(S2)) = S2 then ListBox2.Items.Add(Format('%d, %d', [I, J])); end; finally ListBox2.Items.EndUpdate; end; end;
var i,p : Integer; begin for i:=0 to ListBox1.Items.Count-1 do begin p := Pos(UpperCase(Edit1.Text),UpperCase(ListBox1.Items[i])); if p <> 0 then ListBox2.Items.Add(Format('%d,%d',[i+1,p])); end;
var I, J, P: Integer; S, S2: String; begin S2 := Uppercase(Edit1.Text); // mettre le texte à rechercher ici for I := 0 to ListBox1.Items.Count - 1 do begin P := 0; S := Uppercase(ListBox1.Items.Strings[I]); // on parcourt la ligne actuelle en cherchant des occurrences de S2 for J := 1 to Length(S) - Length(S2) + 1 do if Copy(S, J, Length(S2)) = S2 then Inc(P); // on affiche leur nombre si il y en a if P > 0 then ListBox2.Items.Add(Format('%d, %d',[I + 1, P])); end; end;
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionvar I, J: Integer; S, S2, R: String; begin S2 := Uppercase(Edit1.Text); // mettre le texte à rechercher ici for I := 0 to ListBox1.Items.Count - 1 do begin R := IntToStr(I) + ', '; // on met le numéro de la ligne d'abord S := Uppercase(ListBox1.Items.Strings[I]); // on parcourt la ligne actuelle en cherchant des occurrences de S2 for J := 1 to Length(S) - Length(S2) + 1 do if Copy(S, J, Length(S2)) = S2 then R := R + IntToStr(J) + ', '; // on affiche leur nombre si il y en a ListBox2.Items.Add(Copy(R, 1, Length(R) - 2)); end; end;