sortListBox() 对listbox中的整型数据重小到大排序 并返回最小值

{对listbox中的整型数据重小到大排序 并返回最小值}
//调用 sortListBox(ListBox1);
//listbox的项目必须能转换成整型的数值
function sortListBox(ListBox:TListBox):integer;
var
  I,J:Integer;
  temp:string;
begin 
 if   ListBox.Items.Count=0  then Exit;   
  with  ListBox  do
  begin
   for i:=0 to Count-1   do
    for j:=i to Count-1   do
      if StrToInt(Items[i])>StrToInt(Items[j])   then
        begin
          temp:=Items[i];
          Items[i]:=Items[j];
          Items[j]:=temp;
        end;
  end;
  Result:=StrToInt(ListBox.Items[0]);
end;




你可能感兴趣的:(listbox)