Solved

How to tell if Items in listbox exist

Posted on 2004-03-28
2
257 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

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

810 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