Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Code: When an item isn't selected in a listbox.

Status
Not open for further replies.

MaKiT

Programmer
Oct 23, 2002
2
GB
I need an 'If then else' statement so if text in a listbox is not selected then a message pops up saying 'Please select an item'.

I can do the message bit but I dont know what to put after 'If'.

Any expert help?
 
I just figured it out, funily enough by looking at a visual basic app.
It was:

If listbox1.itemIndex = -1 then
showmessage('Select a File first')
else
...

Thanks for replying though
 
That's why I suggested SelCount property, 'cause you could then do:
Code:
if ListBox1.SelCount > 0 then
begin
    for n := 0 to ListBox1.Count - 1 do
        if ListBox1.Selected[n] then
            ProcessFile(ListBox1.Items[n]);
end
else
    showmessage('Hey dude, select some file!!!');
only to make it multi-file aware.
HTH,
TonHu s-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top