Hi,
I want to read the items of a Listbox (with Checkbox) to store in an Array, their path (previously saved in RowTagAt() as folderitem) of checked items.
But I have an OutOfBoundsException exception in the msgbox
What’s wrong with my code?
Var items() As FolderItem
for x as integer = 0 to Listbox1.RowCount - 1
if Listbox1.CellCheckBoxStateAt(x,0) = DesktopCheckbox.VisualStates.Checked then
items.add(Listbox1.RowTagAt(x) )
msgbox(items(x).ShellPath) <--- OutOfBoundsException!
end
next
You do not always add something to the items Array, while you increment to x count.
So you might end up in a situation where you try to access item(x) but the last index in this Array is lower than x.
If you need the items Array as big as the number of rows in your listbox, add