Consulting

Results 1 to 3 of 3

Thread: Solved: Multi Information from Listbox

  1. #1
    VBAX Regular
    Joined
    Aug 2005
    Posts
    56
    Location

    Solved: Multi Information from Listbox

    Hey guys.
    I have a listbox that collects all the information from a column. All the information in that column has more information tha applies to it in the next columns. Example:
    book 1 - 123 - hello
    book 2 - 234 - goodbye

    the listbox populates the book's. When the user clicks on one of these books in the list box, i have 3 textboxes next to the listbox that i want to display the rest of the information of that item the user clicks on. Now the information the user actually clicks on, thats easy: (textbox: )Pbarcode.Value = ProductBox.Value(Listbox).

    How can i get the other information into those other 2 textboxes? I Know i can do a multi column listbox, but still, it just looks messy ya know? like this its kinda neater. Heres the code i have for further clarification:

    [VBA] Private Sub UserForm_activate()

    Dim mylist(3000, 10)

    i = 2
    j = -1

    Do
    i = i + 1
    j = j + 1
    mylist(j, 0) = Worksheets("Sheet1").Range("A" & i).Value
    mylist(j, 1) = Worksheets("Sheet1").Range("B" & i).Value
    mylist(j, 2) = Worksheets("Sheet1").Range("C" & i).Value

    If mylist(j, 0) = "" Then GoTo contn
    Loop

    contn:
    ProductBox.List() = mylist
    End Sub


    Private Sub ProductBox_Click()
    Pbarcode.Value = ProductBox.Value

    End Sub
    [/VBA]

    thnx fer any help.

  2. #2
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    I think that you mean something like this

    [VBA]
    Private Sub ProductBox_Click()
    PbarCode.Value = ProductBox.Value
    PItem.Value = ProductBox.List(ProductBox.ListIndex, 1)
    PDesc.Value = ProductBox.List(ProductBox.ListIndex, 2)
    End Sub
    [/VBA]
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  3. #3
    VBAX Regular
    Joined
    Aug 2005
    Posts
    56
    Location
    uH! perfect. Thanks alot.

Posting Permissions

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