How to edit all values in listbox by read, insert and remove? VB

I have a listbox in VB 2010 that needs to multiply all values by a number as typed in a textbox. The value must be read, remove and inserted using a loop.

Thanks

Answers


Why remove and reinsert, when you only want to modify the existing values? Try this:

    Dim mult = Val(TextBox1.Text)
    For vIndex = 0 To ListBox1.Items.Count - 1
        Dim newVal = Val(ListBox1.Items(vIndex)) * mult
        ListBox1.Items(vIndex) = Trim(Str(newVal))
    Next

Its simple to update an item in listbox. Just write the above code at your update button's click event.

Dim index As Integer=Listbox1.SelectedIndex
Listbox1.Items.Remove(Listbox1.SelectedItem)
Listbox1.Items.Insert(index,Textbox1.Text)

here textbox contains value to be updated. First write the value in textbox. Then select the item u wish to update with the value of textbox and then click the update button to update the item.


Need Your Help

jquery get image size

jquery image size

I am creating a photo gallery using jquery. I am taking and resizing the images on load to create thumbnails. I want to get the original value of the image's size so that later on I can take it bac...