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!

How do i find out the index im on in a listbox

Status
Not open for further replies.

adi316

Programmer
Sep 10, 2002
35
0
0
CA
i need to have an ok button that returns what index i am on in a listbox. anyone know how to do it? tia
 
Use List1.ListIndex
For the text in that index, use List1.List(List1.ListIndex)

Carlos Paiva
 
The .ListIndex property will return the index for the currently selected item. -1 if no item is selected.

Robert
 
Running this Bit of code will return the index as c

Private Sub Command1_Click()
Dim a, c As Integer

For a = 0 To (List1.ListCount - 1)
If List1.Selected(a) = True Then c = a
Next a
MsgBox (c)
End Sub

the first object in the list will be 0. Thanx Dave Shaw!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top