I try to create visual basic 2010 program that detect which connection is connected and its ip address. For example if i connect with wireless and cable, it will show both media connected and its ip address. This code i take from WMI code creator
Dim strComputer = "."
Dim Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery( _
"SELECT * FROM Win32_NetworkAdapterConfiguration",,48)
For Each objItem in colItems
Wscript.Echo "-----------------------------------"
Wscript.Echo "Win32_NetworkAdapterConfiguration instance"
Wscript.Echo "-----------------------------------"
If isNull(objItem.IPAddress) Then
Wscript.Echo "IPAddress: "
Else
Wscript.Echo "IPAddress: " & Join(objItem.IPAddress, ",")
End If
Then i got error message
'colItems' is not declared. It may be inaccessible due to its protection level.
Am i doing wrongly? Can someone show me if this is the wrong code or not?