DOC: For Each ... Next Statement Does Not Work for Collections (180487)



The information in this article applies to:

  • Microsoft eMbedded Visual Basic 3.0
  • Microsoft Windows CE Toolkit for Visual Basic 6.0

This article was previously published under Q180487

SUMMARY

In the Help topics for eMbedded Visual Basic (eVB) and Microsoft Windows CE Toolkit for Visual Basic (VBCE), the description for the "For Each ... Next" statement is as follows:

"Repeats a group of statements for each element in an array or collection."

However, this is not true for collections because you cannot declare a collection in either eVB or VBCE.

MORE INFORMATION

Unlike the information presented in the Help documentation, the following code will not work in either eVB or VBCE because the New keyword is not supported:
   Private Sub Command1_Click()
      Dim col As New Collection
      Dim vnt
      col.Add "Item1"
      col.Add "Item2"
      col.Add "Item3"
      col.Add "Item4"
      For Each vnt In col
          MsgBox vnt
      Next
   End Sub
				

Modification Type:MinorLast Reviewed:3/11/2005
Keywords:kbpending kbToolkit KB180487