I have these lines of code that are in an app one of my customers is using (Self is a Listbox). There is an exception handler that reports the erln number to the user.
dim erln as single
dim Astr as string
dim Tag as variant
dim Chkd as boolean
'row and column are integers passed to this method
if row<0 or row>=Self.ListCount or SelectedColumn<0 or SelectedColumn>=Self.ColumnCount then return
When the code runs, it raises an Out of Bounds exception erln=2.
In this case, does Out of Bounds actually mean the cell tag is nil? I can’t see where the row and column would change or the size of the listbox would change between erln=1 and erln=2.
I just ran into another case of an Out of Bounds exception that seems equally unlikely:
if row<0 or row>=Me.ListCount then return
if Me.RowTag(row)=nil then return 'OUT OF BOUNDS EXCEPTION RAISED HERE
LisCount is 1 based. You cannot test
I believe you should do
row>=(Self.ListCount-1) in the return line
If row>=(Self.ListCount-1) would return if row is the last possible row in the list, but it shouldn’t
If row >= Self.ListCount should be OK, it’s the same as row > Self.ListCount-1
Right? Or am I losing my mind?
Row is zero based, and ListCount is one based.
Yes, I know ListCount is one based and Row is zero based.
So if ListCount=0 then row>=0 would return, wouldn’t it?
And if ListCount=5 then row>=5 would return.
I’m just using >= instead of using > and subtracting one. Why would that make a difference?
If ListCount = 5, then the highest row is 4. So it should indeed return.
So to repeat my question, In this case, does Out of Bounds actually mean the cell tag is nil?
Just tried to get the celltag of a newly created row where the celltag was not set, no error.
Are you sure the OutOfBoundException is from the LB ?
can a selected column be <0 ?
or CellTag is missing
I’ll do some experimenting, thanks!