G
glacier_gxf
Unregistered / Unconfirmed
GUEST, unregistred user!
这段代码实现功能是:从含有M条Item的ProIDListBox中随机抽取各不相同的N条Items;比如200条,但我在程序执行过程中会发现仍有重复的Item,
While RandomListBox.Items.Count<RandomRzSpinEdit.IntValue Do
begin
if RandomListBox.Items.Count=0 then
RandomListBox.items.Add(ProIDListBox.Items.Strings[random(ProNum)]);
For i:=0 To RandomListBox.Items.Count-1 Do
begin
Str:=ProIDListBox.Items.Strings[random(ProNum)];
if RandomListBox.Items.IndexOf(Str)>0 then
continue
else
RandomListBox.items.Add(Str);
end;
end;
While RandomListBox.Items.Count<RandomRzSpinEdit.IntValue Do
begin
if RandomListBox.Items.Count=0 then
RandomListBox.items.Add(ProIDListBox.Items.Strings[random(ProNum)]);
For i:=0 To RandomListBox.Items.Count-1 Do
begin
Str:=ProIDListBox.Items.Strings[random(ProNum)];
if RandomListBox.Items.IndexOf(Str)>0 then
continue
else
RandomListBox.items.Add(Str);
end;
end;