Home All Groups Group Topic Archive Search About
Author
20 Mar 2006 10:21 PM
tk
I am trying to write a VB.net program that will retrieve info about a
machines hard drive(s). When I try to do a calculation I get and error that
states: Operator is not valid for type 'UInt64' and type 'Integer'. I am
trying to divide the freespace by 1024.  I have tried to declare a variable
as type uint64, but that did not work.  Is there a way to convert the value
returned by WMI to a type that I can perform math on? Below is the code I am
running:

Dim colDisks As System.Management.ManagementObjectCollection

Dim objDisk As System.Management.ManagementObject

Const HARD_DISK = 3

colDisks = WmiConn.ExecWmiQuery("Select * from Win32_LogicalDisk Where
DriveType = " & HARD_DISK & "")

For Each objDisk In colDisks

F = objDisk.GetPropertyValue("freespace") / 1024

next



Any help would be appreciated.



Thanks.

Author
21 Mar 2006 12:20 AM
Ken Tucker [MVP]
Hi,

        Convert it to a long then do math with it.

F = Long.Parse(objDisk.GetPropertyValue("freespace") .ToString) / 1024

Ken
-----------------
Show quoteHide quote
"tk" <timkelley***@mennies.com> wrote in message
news:OqOQ1yGTGHA.1236@TK2MSFTNGP11.phx.gbl...
>I am trying to write a VB.net program that will retrieve info about a
>machines hard drive(s). When I try to do a calculation I get and error that
>states: Operator is not valid for type 'UInt64' and type 'Integer'. I am
>trying to divide the freespace by 1024.  I have tried to declare a variable
>as type uint64, but that did not work.  Is there a way to convert the value
>returned by WMI to a type that I can perform math on? Below is the code I
>am running:
>
> Dim colDisks As System.Management.ManagementObjectCollection
>
> Dim objDisk As System.Management.ManagementObject
>
> Const HARD_DISK = 3
>
> colDisks = WmiConn.ExecWmiQuery("Select * from Win32_LogicalDisk Where
> DriveType = " & HARD_DISK & "")
>
> For Each objDisk In colDisks
>
> F = objDisk.GetPropertyValue("freespace") / 1024
>
> next
>
>
>
> Any help would be appreciated.
>
>
>
> Thanks.
>
>
Author
21 Mar 2006 3:56 AM
TK
Thanks for your help.

Show quoteHide quote
"tk" <timkelley***@mennies.com> wrote in message
news:OqOQ1yGTGHA.1236@TK2MSFTNGP11.phx.gbl...
>I am trying to write a VB.net program that will retrieve info about a
>machines hard drive(s). When I try to do a calculation I get and error that
>states: Operator is not valid for type 'UInt64' and type 'Integer'. I am
>trying to divide the freespace by 1024.  I have tried to declare a variable
>as type uint64, but that did not work.  Is there a way to convert the value
>returned by WMI to a type that I can perform math on? Below is the code I
>am running:
>
> Dim colDisks As System.Management.ManagementObjectCollection
>
> Dim objDisk As System.Management.ManagementObject
>
> Const HARD_DISK = 3
>
> colDisks = WmiConn.ExecWmiQuery("Select * from Win32_LogicalDisk Where
> DriveType = " & HARD_DISK & "")
>
> For Each objDisk In colDisks
>
> F = objDisk.GetPropertyValue("freespace") / 1024
>
> next
>
>
>
> Any help would be appreciated.
>
>
>
> Thanks.
>
>