I'm actually using WMI to get computer information on the workstations
on our network.
Win32_PhysicalMemory returns the "Capacity" property that is in UInt64
form. I'm trying to divide to convert it to MB.
On Fri, 7 Jan 2005 17:05:16 -0600, "Chris, Master of All Things
[quoted text, click to view] Insignificant" <chris@No_Spam_Please.com> wrote:
>Well your error message and your code don't match up. I think you ment to
>type
> Dim X as int32
> Dim Y as UInt64
>
>You need to convert these to Int64 types. Why are you using the UInt64?
>I've never used them myself so I don't know why you would need to use them.
>This code should work though.
>
> Dim X as Double
> Dim Y as UInt64
>'Set Y to something here
> X = Convert.ToDouble(Y)/1024
>
>hope it helps
>Chris
>
>
>"Kevin" <kevinp@cfl.rr.com> wrote in message
>news:9rvtt0ppe0i907q30jrtdcqaqdlt6cqq16@4ax.com...
>> Dim X as int32
>> Dim Y as int64
>>
>> X = Y / 1024
>>
>> gives me the error:
>> "Operator is not valid for type 'UInt64' and type 'Integer'."
>>
>> I'm new to VB.NET and this is one of the reasons why I've resisted so
>> long. I've tried Dimming X as Int64 and integer. What do I have to
>> do to divide this stinkin' number?
>
"Kevin" <kevinp@cfl.rr.com> schrieb:
[quoted text, click to view] > Dim X as int32
> Dim Y as int64
>
> X = Y / 1024
>
> gives me the error:
> "Operator is not valid for type 'UInt64' and type 'Integer'."
I assume you are using 'UInt64' instead of 'Int64'. VB 2002/2003 do not
support unsigned datatypes out of the box, and unsigned datatypes are not
CLS-compliant (in VB 2005 unsigned types will be supported). If possible,
use unsigned datatypes.
--
M S Herfried K. Wagner
M V P <URL:
http://dotnet.mvps.org/> V B <URL:
http://dotnet.mvps.org/dotnet/faqs/>
"Kevin" <kevinp@cfl.rr.com> schrieb:
[quoted text, click to view] > I'm actually using WMI to get computer information on the workstations
> on our network.
>
> Win32_PhysicalMemory returns the "Capacity" property that is in UInt64
> form. I'm trying to divide to convert it to MB.
This cannot be done using VB.NET. You may either want to do that in C# or
use p/invoke to format the number of bytes to a human-readable string, if
you want to display it to the user:
C# code:
\\\
ulong Bytes = ...;
long Megabytes = (long)(i / 1024);
///
Formatting a number of bytes to a string with unit
<URL:
http://dotnet.mvps.org/dotnet/faqs/?id=formatbytes&lang=en> --
M S Herfried K. Wagner
M V P <URL:
http://dotnet.mvps.org/> V B <URL:
http://dotnet.mvps.org/dotnet/faqs/>