all groups > vb.net > january 2005 >
You're in the

vb.net

group:

Can't divide a type UInt64


Re: Can't divide a type UInt64 Chris, Master of All Things Insignificant
1/7/2005 5:05:16 PM
vb.net: 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


[quoted text, click to view]

Can't divide a type UInt64 Kevin
1/7/2005 9:31:51 PM
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
Re: Can't divide a type UInt64 Kevin
1/8/2005 12:41:50 AM
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]
Re: Can't divide a type UInt64 Herfried K. Wagner [MVP]
1/8/2005 12:52:59 AM
"Kevin" <kevinp@cfl.rr.com> schrieb:
[quoted text, click to view]

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/>
Re: Can't divide a type UInt64 Herfried K. Wagner [MVP]
1/8/2005 2:14:15 AM
"Kevin" <kevinp@cfl.rr.com> schrieb:
[quoted text, click to view]

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/>
AddThis Social Bookmark Button