Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


How to Set ListBox.Value

How to Set ListBox.Value

How to Set ListBox.Value

For a ListBox, is setting the ListIndex property the same as setting the value property?

Given a ListBox already populated with;

ListBox.value = "BBBBB" does not set the value but

ListBox.ListIndex = 1 does select BBBBB

Does setting the value also set the ListIndex #?  Is it possible to set the selection by setting the value equal to a member of the list?

RE: How to Set ListBox.Value


Think of the value as read-only.  You insert a list into a listbox.  Each item in the list is a number in the ListIndex.

AAAAA  = 0
BBBBB  = 1
CCCCC  = 2
DDDDD  = 3

You do not, in fact "set" the value of the listbox - except when you populate it in the first place.  Once populated, well, the values ARE set.  They are referenced by the ListIndex.  Their values are fixed to the AddItem entry.

Which is why

MsgBox ListBox1.Value
ListBox1.Value = "Hello"

will display the value, but will fail on setting it.  Listbox.Value can not be set directly...at least not like that.


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close