Florian Müller
Florian Müller

Reputation: 7795

VB Listbox change value

How can i change a value in a VB Listbox?

Like this it doesn't work:

listbox.selectedItem = "Newvalue"

THX for help

Upvotes: 2

Views: 5440

Answers (2)

Laxmi
Laxmi

Reputation: 3810

Adding items to listbox:

ListBox1.Items.Add("AA")
ListBox1.Items.Add("BB")
ListBox1.Items.Add("CC")
ListBox1.Items.Add("DD")

now select anyone 1 option in the listbox:

image1

Add this code in your button click

ListBox1.SelectedItem.Text = "newvalue"

image2

the selected option/value "CC" is changed to "newvalue"

Upvotes: 1

Hangman_1966
Hangman_1966

Reputation: 186

listbox.List(listbox.ListIndex) = "NewValue"

Upvotes: 3

Related Questions