VB listbox cannot be indexed because it has no default value

Posted by Shane Fagan on Stack Overflow See other posts from Stack Overflow or by Shane Fagan
Published on 2010-03-17T16:31:26Z Indexed on 2010/03/17 16:41 UTC
Read the original article Hit count: 371

Filed under:
|
|

I have a listbox and I want to loop through each of the items to see if the string im looking for is inside. I know I could do .contains but that wouldnt look at substrings. The code im using looks like this:

While tempInt > Listbox.items.count then
if searchString.contains(listbox(tempInt)) then
end if
tempInt+=1
end while

Everything in the loop is fine but VB gives an error on the listbox(tempInt) part. The error is "class windows.forms.listbox cannot be indexed because it has no default value". Can anyone help get around the default value crap? I tried putting in a blank string but no change.

© Stack Overflow or respective owner

Related posts about vb.net

Related posts about listbox