+1  A: 

Get rid of the of the on error resume next. Can you post what Foo looks like ?

JonH
+1  A: 

Behold the Evil of On Error Resume Next. It resumes right into the loop when your fooCollection reference is Nothing.

Hans Passant
+2  A: 

IEnumerable and Count aren't related. When you do the For Each you're essentially doing this:

Dim en as IEnumerator = fooCollection.GetEnumerator()
While en.MoveNext()
   d = en.Current()
   ' your code here...
Wend

(Excuse my possibly-rubbish syntax; it's been a while since I've done VB.)

So, the value of your Count property has nothing to do with the functionality of the loop. Have you implemented the IEnumerator yourself? If so, I'd suspect you've done it incorrectly.

Dan Puzey