StringList - encontrando semelhantes entre 2 |
Top Previous Next |
procedure FindCommonStrings(List1, List2: TStringlist; var CommonStrings: TStringlist); // Returns in CommonStrings the stings that are present in both List1 and List2 var Value: String; i : Integer; begin CommonStrings := TStringlist.Create; for i := 1 to List1.Count do begin Value := List1[i-1]; if List2.IndexOf(Value) <> -1 then if CommonStrings.IndexOf(Value) = -1 then CommonStrings.Add(Value); end; for i := 1 to List2.Count do begin Value := List2[i-1]; if List1.IndexOf(Value) <> -1 then if CommonStrings.IndexOf(Value) = -1 then CommonStrings.Add(Value); end; end; |