RemoveRow throws OutofBoundsException

Why would ListBox.RemoveRow throw an OutofBoundsException for multiple selected rows?
I have multiple lines selected, but the LR doesn’t mention anything with handling that.
The Code line is

RCDictList.RemoveRow SlctdRws(ic)

RCDictList.RemoveRow RcDictList is the listbox
SlctdRws is an array of selected rows
ic is the selected row to be deleted.

It works fine with a single selected row and multiple RemoveRow worked fine with an editable list. This one isn’t, but again it works fine with a single Remove.
It has nothing to do with the rows being selected as I set everything to selected = false.

When deleting multiple rows in a listbox, you have to delete them in reverse order, starting from the bottom and moving up

Yep. That’s how the rest is written. It worked fine with “For i = maxSel Down To 0” in my other list - bottom to top or listcount-1 to 0. I didn’t get one row deleted with this multiply selected row list.

that is strange…what version XOJO. I will give it try here

Current release. MacOs 10.7.5. Like most of my problems, they make no sense. Let me know.

You’ll get the OutOfBoundsException if you try to remove a row that does not exist. Multiple selection doesn’t have anything to do with it.

Odds are you just have a subtle bug somewhere in your code. Try uploading a sample project somewhere for people to look at at. Oftentimes, another set of eyes can help.

If I understand it correctly, you have an array of row numbers in SlctdRws and you are deleting one from the listbox based on the row id in the array.

The problem I envision is that unless you are rebuilding the array every time you delete one of the listbox rows, the row numbers in the array no longer correctly represent the row numbers in the listbox. For example, if you have a 12 row listbox and you have an array of (1, 3, 7, 9, 11), if you delete row 3 then rows 7, 9, and 11 become rows 6, 8, and 10 respectively. If you don’t update the array, you will have a problem if you try to delete row 11 (from the array list) since that row will no longer exist.

Figured out the problem. In the line
RCDictList.RemoveRow SlctdRws(ic)

the SlctdRws(ic) isn’t being seen as the contents of the array but the array itself. Does that make sense?
When I set an integer equal to the value of the SlctdRws(ic), then the RemoveRow would work.
What else can I do so I directly use the value of the array?

Figured out how to get the array in that line. Simple after reading the LR. Put it in parentheses.