Hey all,
Ok so what is going on is this:
I've made a file processing utility and that in itself
works fine. But here's something I've been wanting to add:
I want to remove duplicate entries, sometimes there is
duplicate data in the listbox that I am using. And here
lies my problem:
I can easily write a procedure that will remove double
entries but it can't handle it when the same data is in
there 3 or more times which causing the famous "index out
of bounds" error and I haven't a clue in what I am doing
wrong.
The way I do it that works for double entries:
BobbaFet ![[bobafett] [bobafett] [bobafett]](/data/assets/smilies/bobafett.gif)
faq102-5352
Ok so what is going on is this:
I've made a file processing utility and that in itself
works fine. But here's something I've been wanting to add:
I want to remove duplicate entries, sometimes there is
duplicate data in the listbox that I am using. And here
lies my problem:
I can easily write a procedure that will remove double
entries but it can't handle it when the same data is in
there 3 or more times which causing the famous "index out
of bounds" error and I haven't a clue in what I am doing
wrong.
The way I do it that works for double entries:
Code:
procedure RemoveDuplicateEntries;
var i,j: integer;
begin
for i := ListBox1.Items.Count - 1 downto 0 do
begin
for j := i - 1 downto 0 do
if ListBox1.Items.Strings[i] = ListBox1.Items.Strings[j] then
ListBox1.Items.Delete(j);
end;
end;
![[bobafett] [bobafett] [bobafett]](/data/assets/smilies/bobafett.gif)
![[bobafett] [bobafett] [bobafett]](/data/assets/smilies/bobafett.gif)
Code:
if not Programming = 'Severe Migraine' then
ShowMessage('Eureka!');