Member Login

Remember Me
Forgot Password?
Join Us!

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!

Join Tek-Tips
*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.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

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 least not like that.


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