Solved

How to get VBA Listbox text

Posted on 2014-04-11
3
229 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

813 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now