Results 1 to 4 of 4

Thread: Listbox questions

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2002
    Posts
    20

    Listbox questions

    I have a listbox that I fill with data from an array like this:
    Code:
        With Listbox1
            For i = 0 To UBound(Kunder, 2)
                .AddItem (Kunder(1, i) & " " & Kunder(2, i))
            Next
        End With
    That works fine, but now to the problem, every "part" of the array has an number(identifier), Kunder(0, i) that I want to add as an index or something with the data so that when I click on a post in the listbox I can retriev the number for that post. How can I do that?

  2. #2
    PowerPoster
    Join Date
    Nov 2001
    Location
    Trying to reach and stay in the cloud
    Posts
    2,089

    hi

    Perphaops u r looking for:

    Code:
        With Listbox1
            For i = 0 To UBound(Kunder, 2)
                .AddItem (Kunder(1, i) & " " & Kunder(2, i))
                 .ItemData(.NewIndex) = Kunder(0, i) 
           Next
        End With

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jul 2002
    Posts
    20
    Thanx, but what do I write to retrieve the number?

    Code:
    Private Sub Listbox1_Click()
        MsgBox(Listbox1.???)
    End Sub

  4. #4
    Fanatic Member joltremari's Avatar
    Join Date
    Sep 2000
    Location
    Mississippi
    Posts
    674
    After you selecting an item in the list box:
    VB Code:
    1. MsgBox List1.ItemData(List1.ListIndex)
    JO
    "I have not failed. I've just found 10,000 ways that won't work."
    'Thomas Edison'

    "If we knew what it was we were doing it wouldn't be called research, would it?"
    'Albert Einstein'

    VB6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width