Reputation: 69
I have a listbox with items.I am looping through the listbox to get one item at once and to be assigned to a string variable.The question is.. Is there a way to check wether the list contains specified string? Thanks in advance.
Upvotes: 5
Views: 11635
Reputation: 5684
Try it this way:
if ListBox1.Items.IndexOf('yourString') > -1 then
begin
//whatever you want to do if your listbox contains 'yourString'
end;
Upvotes: 14