Advertisement

07.18.2008 at 09:11AM PDT, ID: 23577315
[x]
Attachment Details

Problem with my vb.net Array

Asked by wally_davis in Microsoft Visual Basic.Net

Tags: vb.net, ie 7.0

When I attempt to run the code below, I get the error, "Number of indices is less than the number of dimensions of the indexed array".
It's only a one dimensional array with two indices. Nothing big. Just want to understand passing in Data from the Array to the searcher and For Each Loop. At this point, I've obviously jacked something up. I would appreciate any VB.Net experts input and feedback on what I've done wrong.
Thanks,
WallaceStart Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
Imports System
Imports System.Management
Imports System.Windows.Forms
 
Namespace WMIState
 
    Public Class WMIStateQuery
 
        Public Overloads Shared Function Main() As Integer
 
            Try
	Dim host() as string = {"B001279AE624B", "B001E0BA97371"}
                Dim searcher As New ManagementObjectSearcher( _
                    "\\" & host() & "\root\CIMV2", _
                    "SELECT State FROM Win32_Service Where Name = 'Platform Validation Tool'") 
 
	Dim i as Integer
	For i = 0 To host.Length - 1
	Console.WriteLine("Computer: {0}", host)
                For Each queryObj As ManagementObject in searcher.Get()
	    Console.WriteLine("-----------------------------------")
                    Console.WriteLine("Win32_Service instance")
                    Console.WriteLine("-----------------------------------")
                    Console.WriteLine("State: {0}", queryObj("State"))
                Next
	Next
            Catch err As ManagementException
                MessageBox.Show("An error occurred while querying for WMI data: " & err.Message)
            End Try
        End Function
    End Class
End Namespace
 
Loading Advertisement...
 
[+][-]07.18.2008 at 09:15AM PDT, ID: 22037370

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.18.2008 at 09:23AM PDT, ID: 22037452

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Microsoft Visual Basic.Net
Tags: vb.net, ie 7.0
Sign Up Now!
Solution Provided By: Ruscal
Participating Experts: 2
Solution Grade: A
 
 
[+][-]07.18.2008 at 12:01PM PDT, ID: 22038728

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628