delphi4arab منتديات دلفي للعرب

نسخة كاملة : لماذا يحذف اخر item من اللائحة
أنت حالياً تتصفح نسخة خفيفة من المنتدى . مشاهدة نسخة كاملة مع جميع الأشكال الجمالية .
السلام عليكم

كود :
ListBox1.Sorted := true count := 1    ;    ''     =: Sec_str for i:=0 to ListBox1.Items.Count-1 do begin   First_str := ListBox1.Items[i   if First_str = Sec_str then     count := count + 1   else     if Sec_str <> '' then begin       ''('+ ((ListBox2.Items.Add(Sec_str + '  (' + IntToStr(count)'        count := 1     end;              Sec_str := First_str
السلام عليكم عند الحذف يتغير الترتيب في حلقة for to استخدم downto بدل من ذلك
(19-01-2016, 08:31 AM)S.FATEH كتب : [ -> ]السلام عليكم عند الحذف يتغير الترتيب في حلقة for to استخدم downto بدل من ذلك

شكرا اخي لكن ما زال يحذف اول بند من اللائحة
هل من اجراء بديل يمكننا استعماله اي انه اذا وجد بندين متشابهين في اللائحة تطهر بهكذا الشكل( items (2 ...
كود :
Var count,i : integer; str:string; begin ListBox1.Sorted := true; count := 1; str:=ListBox1.Items[0]; for i:=1 to ListBox1.Items.Count-1 do if str = ListBox1.Items[i] then begin   inc(count);   ListBox1.Items[i]:=ListBox1.Items[i]+'('+IntToStr(count)+')'; end else begin   count := 1;   str:=ListBox1.Items[i]; end; end;
شكرا للجميع هذا جيد لكنه يبقي على ال'item' الاصلي فكيف نلغيه لكي يبقى (items(2 فقط
اخي انت قلت
إقتباس :اذا وجد بندين متشابهين في اللائحة تطهر بهكذا الشكل( items (2
فهل يحذف item الاول ويسمي الثاني( item (2
شكرا اخي لفد وجد الحل begin
ListBox1.Sorted := true
count := 1
str2 := '';
for i:=0 to ListBox1.Items.Count-1 do begin
str1 := ListBox1.Items[i
if str1 = str2 then
count := count + 1
else
if str2 <> '' then
begin
ListBox2.Items.Add(str2 + ' ( ' + IntToStr(count
count := 1
end;

str2 := str1
end;
if count > 1 then
ListBox2.Items.Add(str2 + ' ( ' + IntToStr(count

end
انتبه للحروف الكبيرة Capital Letters عند المقارنة