Reputation: 18149
How do I check if a certain ArrayList index exists?
Upvotes: 1
Views: 15521
Reputation: 185643
That depends on what you mean by "exists".
If you mean "If the ArrayList has an index that high", then you need to look at the Count
:
If arrayList.Count > yourIndex Then
...
End If
If you mean "Does the ArrayList have a value at that index", just check for a null value:
If arrayList(yourIndex) Is Nothing Then
...
End If
Upvotes: 7