• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 246
  • Last Modified:

How to get VBA Listbox text

Hi - I have a listbox with a bunch of items added.  I know how to retrieve which is selected but I can't for the life of me remember how to retrieve the text of the selected item.  Arg...

Thanks!
Zack
0
zack4x4
Asked:
zack4x4
  • 2
1 Solution
 
gplanaCommented:
There is a text property to get the text of a control, so just try this:
mytext =  your_control_name.text

where your_control is your control name.

Hope it helps. Regards.
0
 
gplanaCommented:
Also, if you want to know the text of an element from who you know its item number, you can do this:
     ListBox1.List(i)

where ListBox1 is the name of your ListBox, and i is the index (the selected index on your case).

Regards.
0
 
zack4x4Author Commented:
Awesome thanks!  I tried for like 15 mins trying different things to remember how to do it lol.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now