能,但是需要你自己做程序去处理 procedure TForm1.Button3Click(Sender: TObject); var Tmp: TStringList; i, n: Integer; begin Tmp := TStringList.Create; try Tmp.CaseSensitive := False; //不区分大小写 for i := 0 to ListBox1.Items.Count - 1 do begin n := Tmp.IndexOfName(ListBox1.Items[i]); if n = -1 then Tmp.Add(ListBox1.Items[i] + '=1') else Tmp[n] := Tmp.Names[n] + '=' + IntToStr(StrToInt(Tmp.ValueFromIndex[n]) + 1); end; Memo1.Clear; Memo1.Lines.AddStrings(Tmp); finally Tmp.Free; end; end;上面的代码效率不是很高,但是能完成你要求的任务
procedure TForm1.Button3Click(Sender: TObject);
var
Tmp: TStringList;
i, n: Integer;
begin
Tmp := TStringList.Create;
try
Tmp.CaseSensitive := False; //不区分大小写
for i := 0 to ListBox1.Items.Count - 1 do
begin
n := Tmp.IndexOfName(ListBox1.Items[i]);
if n = -1 then
Tmp.Add(ListBox1.Items[i] + '=1')
else
Tmp[n] := Tmp.Names[n] + '=' + IntToStr(StrToInt(Tmp.ValueFromIndex[n]) + 1);
end;
Memo1.Clear;
Memo1.Lines.AddStrings(Tmp);
finally
Tmp.Free;
end;
end;上面的代码效率不是很高,但是能完成你要求的任务