By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,570 Members | 970 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,570 IT Pros & Developers. It's quick & easy.

Listbox.ItemsSelected

sassy2009
P: 15
Hello All,

I have got a listbox which lists the files from a network folder. I have set the multiselect property to Extended. What iam trying to do now is display the multiple file names from the listbox. The following is the code which i made but instead of returning the selected items value, the code displays NULL n number of times depending on the itemsSelected.count. For example it displays NULL 5 times if i have selected 5 items from the listbox. Please help.....
Expand|Select|Wrap|Line Numbers
  1. Dim frm As Form, ctl As Control
  2.  Dim varItm As Variant
  3.  
  4.     Set frm = Forms!Listing
  5.     Set ctl = frm!lstDisplay
  6.     For Each varItm In ctl.ItemsSelected
  7.         Debug.Print ctl.ItemData(varItm)
  8.     Next varItm
Nov 2 '09 #1
Share this Question
Share on Google+
2 Replies


sassy2009
P: 15
Thanks Guys i just figured it out. Instead of using ItemData i now used Column(0,VarItm) and it worked.
Expand|Select|Wrap|Line Numbers
  1. Dim frm As Form, ctl As Control
  2. Dim varItm As Variant
  3.  
  4. Set frm = Forms!Listing
  5. Set ctl = frm!lstDisplay
  6. For Each varItm In ctl.ItemsSelected
  7.   Debug.Print ctl.ItemData(varItm)
  8. Next varItm
Nov 2 '09 #2

NeoPa
Expert Mod 15k+
P: 31,442
Sassy,

Thanks for posting the solution. Finding that without any knowledge of what's in your Listbox columns would have been a little complicated ;)

Please remember also, that all code must be posted in [ CODE ] tags on this site.

NB. Although the explanation is correct, the code posted seems to be the original, unchanged, code.
Nov 3 '09 #3

Post your reply

Sign in to post your reply or Sign up for a free account.