Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

If Listbox1 string exist in Listbox2 then the item should be deleted

Posted on 2009-03-30
1
292 Views
Last Modified: 2012-05-06
Hey all,

I've got a Listbox1 and Listbox2.

Both are filled with about 50-100 strings and sometimes they contain the same string, if they do I would like for (via button1.click) all the items in Listbox1 that already exist in Listbox2 to be deleted from Listbox1.
0
Comment
Question by:MerlaP83
1 Comment
 
LVL 14

Accepted Solution

by:
SteveBay earned 125 total points
ID: 24020379

procedure TForm1.Button1Click(Sender: TObject);
var i : Integer;
begin
     for i := 0 to ListBox1.Items.Count -1 do
          begin
          if ListBox2.Items.IndexOf(ListBox1.Items[i]) > -1 then
               ListBox2.Items.Delete(ListBox2.Items.IndexOf(ListBox1.Items[i]));
          end;
end;

Open in new window

0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

840 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question