Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / COM / March 2005



Tip: Looking for answers? Try searching our database.

Implements and NewEnum

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Simon Woods - 24 Mar 2005 12:28 GMT
Hi

I want to introduce an  enumerator onto a secondary interface. The
secondary interface already contains a Count and Item-type property

I'm implementing the secondary interface on a Usercontrol which contains
a grid. The effect of the "For each ... in ..."  would be to cycle
through the grid and the NewEnum will return an object containing the
contents of a grid row.

But I'm unsure how to do this! Do I need to implement an IEnumVB-type
interface on the usercontrol and then delegate to it through the
secondary interface ... or can I do it directly from the secondary
interface's implemented call ... or some other way?

Here's the shell

in the calling proc

Private Sub Main
    Process MyUsercontrol.Object
end sub

Private Sub Process(GridData as IMyInterface)

    Dim oGridRowData as clsGridRowData

    For each oGridRowData in GridData
    ... process grid data
    Next oGridRowData

end Sub

in the usercontrol, MyUsercontrol

Implements IMyInterface

Private Property IMyInterface_NewEnum() as IUnknown

   Dim oGridRowData as clsGridRowData

   'load up oGridRowData with data from current row from grid

   ????? - what goes here

End Property

Thanks

Simon
alpine - 24 Mar 2005 16:10 GMT
You need to pass an IEnumVARIANT enumerator object.  For more info you
might want to have a look at the CSuperCollection example in the
Collections section at  http://www.mvps.org/vbvision/

HTH,
Bryan
____________________________________________________________
New Vision Software                   "When the going gets weird,"
Bryan Stafford                     "the weird turn pro."
alpine_don'tsendspam@mvps.org     Hunter S. Thompson -  
Microsoft MVP-Visual Basic     Fear and Loathing in LasVegas

>Hi
>
[quoted text clipped - 46 lines]
>
>Simon
Simon Woods - 24 Mar 2005 16:41 GMT
> You need to pass an IEnumVARIANT enumerator object.  For more info you
> might want to have a look at the CSuperCollection example in the
> Collections section at  http://www.mvps.org/vbvision/
>
> HTH,
> Bryan

Thanks Bryan

I'd just been there ... it seems quite a bit of work to implement this
interface to get a "for each ..." where I could more simply use a "For i
..."

Does the "For each ..." offer signifcant performance improvements or are
there other benefits from implementing the IEnumVARIANT.

S
alpine - 24 Mar 2005 20:01 GMT
>> You need to pass an IEnumVARIANT enumerator object.  For more info you
>> might want to have a look at the CSuperCollection example in the
[quoted text clipped - 13 lines]
>
>S

Actually, I suspect using For Each would be a little less performant
than a standard For....Next loop but don't have any data to back that
up.  The benefits are in the abbreviated syntax used and not having to
determine the array bounds & etc... when setting up the loop.  It is
up to you to decide whether or not implementing the For Each syntax is
worth it in your specific instance.

HTH,
Bryan
____________________________________________________________
New Vision Software                   "When the going gets weird,"
Bryan Stafford                     "the weird turn pro."
alpine_don'tsendspam@mvps.org     Hunter S. Thompson -  
Microsoft MVP-Visual Basic     Fear and Loathing in LasVegas
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.