Get the first item...?

User avatar
ErikJan
5StarLounger
Posts: 1185
Joined: 03 Feb 2010, 19:59
Location: Terneuzen, the Netherlands

Get the first item...?

Post by ErikJan »

Have this code:

Code: Select all

    Set WMI = GetObject("WinMgmts:")
    Set oItems = WMI.InstancesOf("Win32_Processor")
and would like to get the "ProcessorID" from the first item only. Seems I can't use an index.... is it true that the only way is like this?

Code: Select all

    For Each oItem In oItems
        Debug.Print oItem.ProcessorID
        Exit For
    Next

User avatar
HansV
Administrator
Posts: 78235
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Get the first item...?

Post by HansV »

It looks like you are correct - the oItems object does not have an Items collection or something like that.
Best wishes,
Hans