Finding Value of the First Item in a List Box

L

LA Lawyer

I need to know the value of the first (OR ONLY) listed item (the value of the
first column) in a List Box.

My ListBox is named ListOfPeople.
 
D

Dirk Goldgar

LA Lawyer said:
I need to know the value of the first (OR ONLY) listed item (the value of
the
first column) in a List Box.

"The first column", or the first row? From what you said, I'm guessing that
you mean the first row.
My ListBox is named ListOfPeople.

Here's example code:

Dim varFirstValue As Variant

With MeMe.ListOfPeople
If .ListCount > Abs(.ColumnHeads) Then
varFirstValue = .ItemData(Abs(.ColumnHeads))
Else
' The list box is empty.
varFirstValue = Null
End If
End With

I'm assuming that you want the value of the list box's bound column, for the
first non-header row. It is possible to get other columns using the .Column
property.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top