PDA

View Full Version : Solved: Multi Information from Listbox



russkie
10-27-2005, 07:46 AM
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:

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


thnx fer any help.

Bob Phillips
10-27-2005, 09:02 AM
I think that you mean something like this


Private Sub ProductBox_Click()
PbarCode.Value = ProductBox.Value
PItem.Value = ProductBox.List(ProductBox.ListIndex, 1)
PDesc.Value = ProductBox.List(ProductBox.ListIndex, 2)
End Sub

russkie
10-27-2005, 09:20 AM
uH! perfect. Thanks alot.