Pramod schrieb:
> Hi All,
> I have following vbscript code:
> --------------------------------------------------------------------------- -----------------------------------------------------------------
> set sampleObject = CreateObject("SampleType") -- COM component proxy
> set hddObject = sampleObject.GetAllHDDs("comp1")
> --------------------------------------------------------------------------- -----------------------------------------------------------------
> GetAllHDDs function returns a list of objects (List<>). How do I
> iterate through all the objects from the list?
Everything in .NET and also COM that goes by the name of
Collection, List, Array most likely implements some kind
of IEnumerable-interface.
There are two of these interfaces in .NET and some in COM,
they're all subtly different, but share the ability of
being "ForEach-able". That is: You can iterate such an object
in a For Each loop getting one of its items returned
in each step.
set sampleObject = CreateObject("SampleType") -- COM component proxy
set hddCollection = sampleObject.GetAllHDDs("comp1")
For Each hddItem in hddCollection
WSH.Echo "here's the next item of type: " & typename(hddItem)
Next
> so I want to pass the same object to another function.
So you should pass it to that function, you don't have to
worry 'bout types or calling conventions in VBScript.
It's all passed by ref and wrapped into variants.
Christoph