1

I have the follow class in vb6:

Public Function NewEnum()
    Attribute NewEnum.VB_UserMemId = -4
    Attribute NewEnum.VB_MemberFlags = "40"

    NewEnum = mcolFields.[_NewEnum]

End Function

What would the equivalent attributes be in vb.net? I know that you have to put attributes in <>and I also found this SO post, however it didn't solve my problem.

Community
  • 1
  • 1
JabbaWook
  • 677
  • 1
  • 8
  • 25

2 Answers2

3

GetEnumerator() is the exact equivalent. It gets exposed as NewEnum in <ComVisible(True)> code. Simply implement the System.Collections.IEnumerable interface, the non-generic one.

Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
1

Some info about this is here: https://christopherjmcclellan.wordpress.com/2015/04/21/vb-attributes-what-are-they-and-why-should-we-use-them/

There is one more special value for VB_UserMemId and that value is -4. Negative 4 always indicates that the function being marked should return a [_NewEnum] enumerator.

I would say that in this case you can ignore them. So your equivalent should be something like this:

Public Function NewEnum() As mcolFields
    Return New mcolFields
End Function
Matt Wilko
  • 26,994
  • 10
  • 93
  • 143