Link to home
Start Free TrialLog in
Avatar of computerprogramer
computerprogramer

asked on

How to tell if Items in listbox exist

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
Avatar of DragonSlayer
DragonSlayer
Flag of Malaysia image

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!');
ASKER CERTIFIED SOLUTION
Avatar of shaneholmes
shaneholmes

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial