COM enumerable

I'm writing a COM component, basically an enumerable class (so I can use the for .. each loop from VBA).

I managed to write the Following wich work:
<ComClass(FieldValidators.ClassId, FieldValidators.InterfaceId, FieldValidators.EventsId)>
Public Class FieldValidators
    Implements IEnumerable

#Region "GUID COM"
    Public Const ClassId As String = "2d368af9-55a7-4cca-a79d-06b6c3a91554"
    Public Const InterfaceId As String = "5094acfa-2799-491d-b7f0-ebc4a2d0e755"
    Public Const EventsId As String = "a31bb5c3-99c6-4548-85cc-fbe83d407867"
#End Region

    Private mFieldValidators As List(Of IFieldValidator)

    Public Sub New()
        MyBase.New()
        mFieldValidators = New List(Of IFieldValidator)
    End Sub

    Protected Overrides Sub Finalize()
        mFieldValidators = Nothing
        MyBase.Finalize()
    End Sub

    Public Sub Add(ByRef validator As IFieldValidator)
        mFieldValidators.Add(validator)
    End Sub

    Public Function Count() As Long
        Count = mFieldValidators.Count
    End Function

    Public Iterator Function GetEnumerator() As IEnumerator Implements IEnumerable.GetEnumerator
        For Each fieldValidator In mFieldValidators
            Yield fieldValidator
        Next
    End Function

    Default Public ReadOnly Property item(ByVal index As ULong) As IFieldValidator
        Get
            item = mFieldValidators(index)
        End Get
    End Property
End Class

Open in new window

But the resulting enumerator is poorly typed (IEnumVARIANT), I would like to return objects of type IFieldValidator.

Is it doable ?
LVL 12
Fabrice LambertFabrice LambertAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ste5anSenior DeveloperCommented:
Did you publish IFieldValidator?
0
Fabrice LambertFabrice LambertAuthor Commented:
Yeah, it is an interface (as the name suggest it).
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.