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

How can I loop thru a listbox and display the contents of column 1

Status
Not open for further replies.

colezpapa

Programmer
Feb 26, 2007
86
US
How can I loop thru a listbox and display the contents of column(1).

Dim item As Integer
Dim x As String


For Each item In Me.list_FieldsFrom.ItemsSelected
index = Me.list_FieldsFrom.ItemData(item)

MsgBox Me.list_FieldsFrom.Column(1)

Next

Thanks
 
Code:
 Dim ctl As Control
    Dim varitm As Variant
    Dim strX As String

    
    Set ctl = Me.list_FieldsFrom
    strX = ""

    For Each varitm In ctl.ItemsSelected
        If strX = "" Then
            strX = ctl.Column(1, varitm)
        Else
            strX = strX & ", " & ctl.Column(1, varitm)
        End If
    Next varitm

    MsgBox strX


Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244. Basics at
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top