[RESOLVED] Loop though an object getting key and value
I am looking to replace something like
VB Code:
Private Sub Form_Load()
Dim Row As Object
For Each Row In GetObject("winmgmts:\\127.0.0.1\root\CIMV2"). _
ExecQuery("SELECT ScreenHeight,ScreenWidth FROM Win32_DesktopMonitor", "WQL", &H10 + &H20)
Debug.Print "ScreenHeigh", Row.ScreenHeight
Debug.Print "ScreenWidth", Row.ScreenWidth
Next
End Sub
with
VB Code:
Private Sub Form_Load()
Dim Row As Object
Dim Col As Object
For Each Row In GetObject("winmgmts:\\127.0.0.1\root\CIMV2"). _
ExecQuery("SELECT ScreenHeight,ScreenWidth FROM Win32_DesktopMonitor", "WQL", &H10 + &H20)
For Each Col In Row
Debug.Print Key(Col), Value(Col)
Next
Next
End Sub
Second example don't wanna work.
Edit: fixed a typ0.
Re: Loop though an object getting key and value
Try:
VB Code:
Dim Rows As Object
Dim Row As Object
Dim Col As Object
Dim winMgmts As Object
Set winMgmts = GetObject("winmgmts:\\127.0.0.1\root\CIMV2")
Set Rows = winMgmts. _
ExecQuery("SELECT ScreenHeight,ScreenWidth FROM Win32_DesktopMonitor", "WQL", &H10 + &H20)
For Each Row In Rows
For Each Col In Row.Properties_
Debug.Print Col.Name, Col.Value
Next
Next
Regards,
- Aaron.