K
Kurt Garnjost
In the following code, while looping through the array,
dblNumbers, the element reference suddenly goes from 7 to
366, when the referenced array has only 9 items, causing
a "Subscript Out of Range" error.
For Each i In dblNumbers
If dblNumbers(i) = dblExNum Then
booAlrdyUsed = True
Exit For
End If
Next i
The referenced array has only 9 items at this point. Can
anyone explain this behavior?
The following code is work around:
For i = 0 To UBound(dblNumbers)
If dblNumbers(i) = dblExNum Then
booAlrdyUsed = True
Exit For
End If
Next i
However, I would very much like to know why the other
approach is failing. It is in a While ... Wend loop,
which periodically adds an element to the array. The
array has nine elements at the point at which the problem
occurs. There is nothing unusual about the point in the
Word document, where the problem crops up. It is the same
as the 15 or so items processed before this point without
complaint.
Kurt Garnjost
dblNumbers, the element reference suddenly goes from 7 to
366, when the referenced array has only 9 items, causing
a "Subscript Out of Range" error.
For Each i In dblNumbers
If dblNumbers(i) = dblExNum Then
booAlrdyUsed = True
Exit For
End If
Next i
The referenced array has only 9 items at this point. Can
anyone explain this behavior?
The following code is work around:
For i = 0 To UBound(dblNumbers)
If dblNumbers(i) = dblExNum Then
booAlrdyUsed = True
Exit For
End If
Next i
However, I would very much like to know why the other
approach is failing. It is in a While ... Wend loop,
which periodically adds an element to the array. The
array has nine elements at the point at which the problem
occurs. There is nothing unusual about the point in the
Word document, where the problem crops up. It is the same
as the 15 or so items processed before this point without
complaint.
Kurt Garnjost