My code:
If List.Listcount > 0 then
For intI = 0 to List.Listcount - 1
'code
Next intI
End If
For some reason, and not all the time, this loop only runs to the second last entry. I have even witnessed it in break mode and following it step by step with Shift + F8, where it reports - for example - that the listcount is 14, when if fact it is 15 and has index values of 0 to 14. I made a quick fix, but I don't like this solution as it affects my ability to bug test the rest of the sub.
Quick and dirty fix:
On Error Resume Next
If List.Listcount > 0 then
For intI = 0 to List.Listcount
'code
Next intI
End If
This way if listcount is correct, the loop will error on the last value, but will simply resume after the loop, but when it reports it incorrectly, it should still retrieve all items in the list.
My question is why is the listcount property not reporting the correct value, if anybody else has encountered this problem, and if anybody knows a better fix for this. (ps. the ubound property is even less reliable for me)
If List.Listcount > 0 then
For intI = 0 to List.Listcount - 1
'code
Next intI
End If
For some reason, and not all the time, this loop only runs to the second last entry. I have even witnessed it in break mode and following it step by step with Shift + F8, where it reports - for example - that the listcount is 14, when if fact it is 15 and has index values of 0 to 14. I made a quick fix, but I don't like this solution as it affects my ability to bug test the rest of the sub.
Quick and dirty fix:
On Error Resume Next
If List.Listcount > 0 then
For intI = 0 to List.Listcount
'code
Next intI
End If
This way if listcount is correct, the loop will error on the last value, but will simply resume after the loop, but when it reports it incorrectly, it should still retrieve all items in the list.
My question is why is the listcount property not reporting the correct value, if anybody else has encountered this problem, and if anybody knows a better fix for this. (ps. the ubound property is even less reliable for me)
Comment