lbEvents.addRow "1"
lbEvents.cell( i, 0 ) = sDate
lbEvents.cell( i, 1 ) = sType
The above code gets an OutOfBoundsException when adding the 8th row to the lbEvents ListBox. i = 7 and sDate = “2016/07/07” (from the debugger window). The data from the same table is properly shown in another form without problem - including the same row causing the problem here.
I read the docs on OutOfBoundException and it doesn’t give me a clue what might be wrong (there are 25 displayed rows on the listbox though I know that doesn’t have anything to do with it, but just the same…)
Where do I look for a problem? Have traced with debugger multiple times and it gets the same error at the same point each time.
Actually, I found the problem. What I didn’t include in the code was that it is being executed inside an IF statement. And I had mistakenly left the i=i+1 line outside the IF which was apparently causing the problem. Moved the increment statement to the correct place and all worked correctly.
Very sorry to have jumped the gun and bothered you folks before I had fully researched the problem…
Actually, that’s often the best way to find the problem, I’ve found. Once you’ve composed the post, the solution usually becomes obvious milliseconds after you press the ‘Start Conversation’ button. That button is one of my favorite debugging tools.