Solved

How to tell if Items in listbox exist

Posted on 2004-03-28
2
255 Views
Last Modified: 2010-04-05
Hey,

How can I tell if there are items in a listbox. So when I click on a button it will say "items exist" if there are items in the listbox and if there are no items in the listbox it will say "no items in the listbox".

Cheers,

Computer Programer
0
Comment
Question by:computerprogramer
2 Comments
 
LVL 14

Expert Comment

by:DragonSlayer
ID: 10697740
let's say you typed the string to search for in an edit box called Edit1

to test it, just say:

if ListBox1.Items.IndexOf(Edit1.Text) <> -1 then
  ShowMessage('Item Exists!')
else ShowMessage('No such item in the listbox!');
0
 
LVL 11

Accepted Solution

by:
shaneholmes earned 25 total points
ID: 10698424
You can test the Items count property to see if it is zero or not (zero being empty)

if ListBox1.Items.Count > 0 then
 ShowMessage('Items = ' + IntToStr(ListBox1.Items.Count)) //not empty
else
 ShowMessage('Items = 0'); //empty

Shane
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now