Solved

How to get VBA Listbox text

Posted on 2014-04-11
3
231 Views
Last Modified: 2014-04-11
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
Comment
Question by:zack4x4
  • 2
3 Comments
 
LVL 15

Accepted Solution

by:
gplana earned 500 total points
ID: 39994572
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
 
LVL 15

Expert Comment

by:gplana
ID: 39994580
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
 
LVL 4

Author Closing Comment

by:zack4x4
ID: 39994746
Awesome thanks!  I tried for like 15 mins trying different things to remember how to do it lol.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question