2019r2 IDE sometimes making wrong recommendation

I’ve noticed a couple of cases:

  1. I was using PopupMenu.Text to get the text of the selected item. The IDE wants me to change that to .Value, which doesn’t exist for a popup menu.

  2. In the CellBackgroundPaint event for a Listbox, in 2019r1.1 I was doing this at the top of the handler:

if (row>me.LastIndex) then return True

The 2019r2 IDE suggested .LastAddedRowIndex instead of .LastIndex, but what I actually need there is:

if (row>me.LastRowIndex) then return True

Following the IDE suggestion gave me an out-of-bounds exception, as my action was to delete a row.

[quote=457653:@Tim Streater]The 2019r2 IDE suggested .LastAddedRowIndex instead of .LastIndex, but what I actually need there is:

if (row>me.LastRowIndex) then return True
Following the IDE suggestion gave me an out-of-bounds exception, as my action was to delete a row.[/quote]
Actually not.

Listbox.LastIndex refers to the last index that was created with a call to AddRow. The new one is appropriately called LastAddedRowIndex.

What is now LastRowIndex is what ListCount used to be, and will always be the zero-based index of the last row in the list. In other words, ListCount - 1.