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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting the listindex in a listbox 2

Status
Not open for further replies.

Askeladden

Programmer
Jan 28, 2004
87
0
0
NO
Getting the listindex in a listbox, without knowing what the position of chosen item.
For ex. I have a name that is in a listbox (which is not visiable). The user types a name into a textbox. Is there a way to get its listindex?
:)
 
For i = lstItems2.ListCount - 1 To 0 Step -1
If lstItems2.List(i) = txtName.text Then

i would be your listindex :)
 
Thank RubenV.
I pressed Submit to fast. The name should be delete from the list. :)
 
Pressed it too fast again!
Is there a way to delete the name from the list without knowing its listindex?
:)
 
No, you need to get the index first.

Use RubenV's example:

For i = lstItems2.ListCount - 1 To 0 Step -1
If lstItems2.List(i) = txtName.text Then
lstItems2.removeitem i
end if
next i

[gray]Experience is something you don't get until just after you need it.[/gray]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top