StringList - não permitir duplicados |
Top Previous Next |
#1 Não permitir duplicados var L: TStringList; I: Integer; begin L:= TStringList.Create;
L.Sorted := True; L.Duplicates := dupIgnore; // serão ignorados
L.Add('A'); L.Add('B'); L.Add('C'); L.Add('A'); L.Add('B');
for I := 0 to L.Count - 1 do Caption := Caption + ' ' + L[I]; // aparece 'A B C'
L.Free; end;
# 2 Forma alternativa de entrar dados
var L: TStringList; I: Integer; begin L:= TStringList.Create; L.DelimitedText := 'Fusca Fiat147 Corcel Opala Passat';
for I := 0 to L.Count - 1 do // count = 5! Caption := Caption + ',' + L[I];
L.Free; end; |