ListBox: RowFromXY Crash (when used)

Dim row,column as Integer row=Me.RowFromXY(System.MouseX - Me.Left - Self.Left, System.MouseY - Me.Top - Self.Top) column=Me.ColumnFromXY(System.MouseX - Me.Left - Self.Left, System.MouseY - Me.Top - Self.Top) MsgBox "You double-clicked in cell "+Str(row)+", "+Str(column)

I do not use the MsgBox from teh example above, but the code crash in my code when I use Row, Column (one or both: I do not have the code handly).

To avoid that, I checked if Row or Column value is > -1 (I think) and I exit the method if this is the case. The code does not crash anymore.

It crash when I click in the vertical ScrollBar and in a Row or in the part without row…

I can send more data if needed.

Nota: the code does not crash by itself, it is the use of Row or Column that crash: thus my test to be sure their value is above -1.

In which event is your code above?

If you had a hard crash what does the crash log look like?

Yes, either Row or Column or both could return -1. You need to test for that. Not doing so would be a bug in your code, and lead to a crash. But you know that now.

Hi,

thank you for your answers.

In MouseDown.

Crash in the debugger with the “offending” line highlighted. I ran the project a whole day or so until I resolve the issue (partially with an on err… stuff, then adding a check for -1).

Not in the docs and new to me (or I totally forgot about it).

Row could certainly be -1 if the user clicks in the header of the Listbox. Column would be -1 if the user managed to click on the left or right border of the control as well.

Funny, it used to be in the docs. File a feedback against the documentation.

I have to investigate more, but I found an error in my code (oups)

I used ListIndsex instead of ListCount (Usually I my mistake is with LastIndex).

I continue to use the project, but I forgot to click in the location where it bugged previously (and I think at that right now).

Have a happy new year all.