List index out of bounds whilst deleting items
I solved my problem but I need to know why this problem raised to me ?! I write a project that load file to listBox then delete the strings one by one, but when I delete listBox strings this exception raised to me! list index out of bounds (5) ! I type this for loop to read list box and delete strings: for i := 0 to ListBox3.Count -1 do begin ShowMessage(ListBox3.Items[i]); ListBox3.items.Delete(i); end; and my problem solved by do a little change in for-loop statement for i := ListBox3.Items.Count - 1 downto 0 do begin ShowMessage(ListBox3.Items[i]); ListBox3.items.Delete(i); end; Why the