Selecting rows with code


is it possible to select the listbox row with code ?

I have 10 rows in a listbox, how to select 3 rows only from row number 3 to row number 5, without using the mouse to select, I want to copy that 3 rows into another listbox.

[code] For i = 3 to listbox.ListCount-1

this code is not work like expected.


Look at .Selected for example…

Edit: do not forget to set the SelectionType to multiple (it is 1 bydefault).

I would use start and stop as integer variables so this can be modularized
Also, remember listboxes are 0-based by default so you must change this or program around it

//Just in case listbox1.SelectionType = 1 For i as Integer = start to stop listbox1.Selected( i ) = True Next

*I haven’t tested this, but it should work