1

How do I check if a certain ArrayList index exists?

1
  • Please clarify what you mean by an index "existing". Commented Jan 28, 2011 at 21:01

1 Answer 1

7

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
Sign up to request clarification or add additional context in comments.

1 Comment

Can I check in a 2d array for inner values such as i(2)? sArray = Array(Array("01probe", dbInteger), _ Array("02datum", dbDate), _ Array("03bodenart", dbText, 100, True) _ )

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.