Home All Groups Group Topic Archive Search About

uint32 conversion on win32_pingstatus

Author
11 Jan 2006 1:10 AM
James
Dim str As String = "select * from win32_pingstatus where address=
'192.168.0.1'"
        Dim search1 As New ManagementObjectSearcher(str)
        Dim result As ManagementObject

        Try
            For Each result In search1.Get
                If result("statuscode") = 0 Then
                    Console.WriteLine("computer response")
                Else
                    Console.WriteLine("invalid computer")
                End If
            Next
        Catch ex As Exception
            Console.WriteLine(ex.Message)
        End Try


i keep on getting exception error : Cast from type 'UInt32' to type
'Integer' is not valid. Pls advise

Author
11 Jan 2006 1:39 AM
Ken Tucker [MVP]
Hi,

            Try this.

Dim intResult As Integer = Integer.Parse(result("statuscode").ToString)

If intResult = 0 Then



Ken

--------------------------

Show quoteHide quote
"James" <jkk***@hotmail.com> wrote in message
news:uVj1gtkFGHA.1028@TK2MSFTNGP11.phx.gbl...
>
>        Dim str As String = "select * from win32_pingstatus where address=
> '192.168.0.1'"
>        Dim search1 As New ManagementObjectSearcher(str)
>        Dim result As ManagementObject
>
>        Try
>            For Each result In search1.Get
>                If result("statuscode") = 0 Then
>                    Console.WriteLine("computer response")
>                Else
>                    Console.WriteLine("invalid computer")
>                End If
>            Next
>        Catch ex As Exception
>            Console.WriteLine(ex.Message)
>        End Try
>
>
> i keep on getting exception error : Cast from type 'UInt32' to type
> 'Integer' is not valid. Pls advise
>
>