Solved

How to get VBA Listbox text

Posted on 2014-04-11
3
227 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
Comment Utility
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
Comment Utility
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
Comment Utility
Awesome thanks!  I tried for like 15 mins trying different things to remember how to do it lol.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate how to use a scrolling table in Microsoft Excel using the INDEX function.

771 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

13 Experts available now in Live!

Get 1:1 Help Now