다음을 통해 공유


방법: Visual Basic에서 컬렉션 반복

For Each 루프를 사용하여 컬렉션의 모든 요소를 반복할 수 있습니다.

예제

다음 예제에서는 For Each...Next 문(Visual Basic)을 사용하여 컬렉션의 모든 항목에 액세스합니다.

Dim testCollection As New Microsoft.VisualBasic.Collection()
' The collection is empty until you add one or more items to it.
For Each collectionItem As Object In testCollection
    ' Perform desired processing on each item.
Next collectionItem

코드 컴파일

이 예제에는 다음 사항이 필요합니다.

  • System 네임스페이스에 대한 액세스 권한

참고 항목

작업

방법: 컬렉션의 항목 추가, 삭제 및 검색(Visual Basic)

참조

For Each...Next 문(Visual Basic)

개념

Visual Basic의 컬렉션