OutofBounds Exception

I get an OutofBounds exception when an empty ListBox is pressed in the DoublePressed event when running the code. The following code stops execution but allows the App to continue running if I select resume. I don’t have a Desktop license yet to build. Wondering if this will work in a built stand alone App.

  Window1.ListIDLabel.Text=Me.CellTextAt(Me.SelectedRowIndex, 1)
  Window1.ListItemTextField.Text=Me.CellTextAt(Me.SelectedRowIndex, 0)
Catch e as RuntimeException
  If e IsA EndException Or e IsA ThreadEndException Then
    Raise e // Re-raise the exception for the framework
  End If
  MsgBox(e.Message+"Blank Entry Selected")
end Try

There are no differences like that between the standalone vs debug version. Likely your SelectedRowIndex is -1, and that is out of bounds. Check for that before attempting the set the label.

Thanks Kem. I didn’t think so but wanted to make sure. I’ll try your suggestion.

SelectedRowIndex produces -1 when the user clicks below the last row in the ListBox, but still within its bounds.

This works, Thank you for the prompt responses and help.

If me.SelectedRowIndex=-1 Then
  MsgBox("Empty Selection")
  Window1.ListIDLabel.Text=Me.CellTextAt(Me.SelectedRowIndex, 1)