Using array to store selected items in list box

vendredi 10 avril 2015

Hello! I need help with this: I want to use an array to store data from a list box into a variable. I want it to be able to store one value, or multiple values, depending on what is selected.



Main problem: this list box feeds off a table which has employee names and their e-mails. The list box itself only shows the names, and when I select what I want the array to store is their e-mails, not their names.




Code:



Dim strNames As String

Dim varItem As Variant

Dim intCount As Integer



For Each varItem In Me.lstNames.ItemsSelected

intCount = intCount + 1

Select Case Len(strNames)

Case 0

strNames = Me.lstNames.ItemData(varItem)

End Select

Next



MsgBox strNames



That code successfully displays the item I selected, but only displays the name. I need to make it look in the table and get me column #2. I also want it to be able to select more than one item at a time.



Some example code would be amazing, since I'm pretty new to this.

Using array to store selected items in list box

0 commentaires:

Enregistrer un commentaire

Labels